Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,80 @@
<?php
namespace Drupal\{{ machine_name }}\Plugin\Action;
{% if configurable %}
use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
{% else %}
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
{% endif %}
/**
* Provides a {{ plugin_label|article }} action.
*
* @Action(
* id = "{{ plugin_id }}",
* label = @Translation("{{ plugin_label }}"),
* type = "node",
* category = @Translation("{{ category }}")
* )
*
* @DCG
* For simple updating entity fields consider extending FieldUpdateActionBase.
*/
class {{ class }} extends {{ configurable ? 'ConfigurableActionBase' : 'ActionBase' }} {
{% if configurable %}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return ['title' => ''];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['title'] = [
'#title' => t('New title'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => $this->configuration['title'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['title'] = $form_state->getValue('title');
}
{% endif %}
/**
* {@inheritdoc}
*/
public function access($node, AccountInterface $account = NULL, $return_as_object = FALSE) {
/** @var \Drupal\node\NodeInterface $node */
$access = $node->access('update', $account, TRUE)
->andIf($node->title->access('edit', $account, TRUE));
return $return_as_object ? $access : $access->isAllowed();
}
/**
* {@inheritdoc}
*/
public function execute($node = NULL) {
/** @var \Drupal\node\NodeInterface $node */
{% if configurable %}
$node->setTitle($this->configuration['title'])->save();
{% else %}
$node->setTitle(t('New title'))->save();
{% endif %}
}
}