Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -58,32 +58,32 @@ abstract class ActionFormBase extends EntityForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$form['label'] = array(
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Label'),
|
||||
'#default_value' => $this->entity->label(),
|
||||
'#maxlength' => '255',
|
||||
'#description' => $this->t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['id'] = array(
|
||||
$form['id'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#default_value' => $this->entity->id(),
|
||||
'#disabled' => !$this->entity->isNew(),
|
||||
'#maxlength' => 64,
|
||||
'#description' => $this->t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'),
|
||||
'#machine_name' => array(
|
||||
'exists' => array($this, 'exists'),
|
||||
),
|
||||
);
|
||||
$form['plugin'] = array(
|
||||
'#machine_name' => [
|
||||
'exists' => [$this, 'exists'],
|
||||
],
|
||||
];
|
||||
$form['plugin'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $this->entity->get('plugin'),
|
||||
);
|
||||
$form['type'] = array(
|
||||
];
|
||||
$form['type'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $this->entity->getType(),
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->plugin instanceof PluginFormInterface) {
|
||||
$form += $this->plugin->buildConfigurationForm($form, $form_state);
|
||||
|
|
|
@ -86,10 +86,10 @@ class ActionListBuilder extends ConfigEntityListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildHeader() {
|
||||
$header = array(
|
||||
$header = [
|
||||
'type' => t('Action type'),
|
||||
'label' => t('Label'),
|
||||
) + parent::buildHeader();
|
||||
] + parent::buildHeader();
|
||||
return $header;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class ActionListBuilder extends ConfigEntityListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultOperations(EntityInterface $entity) {
|
||||
$operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : array();
|
||||
$operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : [];
|
||||
if (isset($operations['edit'])) {
|
||||
$operations['edit']['title'] = t('Configure');
|
||||
}
|
||||
|
|
|
@ -50,33 +50,33 @@ class ActionAdminManageForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$actions = array();
|
||||
$actions = [];
|
||||
foreach ($this->manager->getDefinitions() as $id => $definition) {
|
||||
if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\PluginFormInterface')) {
|
||||
$key = Crypt::hashBase64($id);
|
||||
$actions[$key] = $definition['label'] . '...';
|
||||
}
|
||||
}
|
||||
$form['parent'] = array(
|
||||
$form['parent'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Create an advanced action'),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#attributes' => ['class' => ['container-inline']],
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['parent']['action'] = array(
|
||||
];
|
||||
$form['parent']['action'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Action'),
|
||||
'#title_display' => 'invisible',
|
||||
'#options' => $actions,
|
||||
'#empty_option' => $this->t('Choose an advanced action'),
|
||||
);
|
||||
$form['parent']['actions'] = array(
|
||||
];
|
||||
$form['parent']['actions'] = [
|
||||
'#type' => 'actions'
|
||||
);
|
||||
$form['parent']['actions']['submit'] = array(
|
||||
];
|
||||
$form['parent']['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Create'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class ActionAdminManageForm extends FormBase {
|
|||
if ($form_state->getValue('action')) {
|
||||
$form_state->setRedirect(
|
||||
'action.admin_add',
|
||||
array('action_id' => $form_state->getValue('action'))
|
||||
['action_id' => $form_state->getValue('action')]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
// If the recipient is a registered user with a language preference, use
|
||||
// the recipient's preferred language. Otherwise, use the system default
|
||||
// language.
|
||||
$recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient));
|
||||
$recipient_accounts = $this->storage->loadByProperties(['mail' => $recipient]);
|
||||
$recipient_account = reset($recipient_accounts);
|
||||
if ($recipient_account) {
|
||||
$langcode = $recipient_account->getPreferredLangcode();
|
||||
|
@ -137,13 +137,13 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
else {
|
||||
$langcode = $this->languageManager->getDefaultLanguage()->getId();
|
||||
}
|
||||
$params = array('context' => $this->configuration);
|
||||
$params = ['context' => $this->configuration];
|
||||
|
||||
if ($this->mailManager->mail('system', 'action_send_email', $recipient, $langcode, $params)) {
|
||||
$this->logger->notice('Sent email to %recipient', array('%recipient' => $recipient));
|
||||
$this->logger->notice('Sent email to %recipient', ['%recipient' => $recipient]);
|
||||
}
|
||||
else {
|
||||
$this->logger->error('Unable to send email to %recipient', array('%recipient' => $recipient));
|
||||
$this->logger->error('Unable to send email to %recipient', ['%recipient' => $recipient]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,39 +151,39 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'recipient' => '',
|
||||
'subject' => '',
|
||||
'message' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['recipient'] = array(
|
||||
$form['recipient'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Recipient'),
|
||||
'#title' => t('Recipient email address'),
|
||||
'#default_value' => $this->configuration['recipient'],
|
||||
'#maxlength' => '254',
|
||||
'#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an email to the author of the original post.'),
|
||||
);
|
||||
$form['subject'] = array(
|
||||
'#description' => t('You may also use tokens: [node:author:mail], [comment:author:mail], etc. Separate recipients with a comma.'),
|
||||
];
|
||||
$form['subject'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject'),
|
||||
'#default_value' => $this->configuration['subject'],
|
||||
'#maxlength' => '254',
|
||||
'#description' => t('The subject of the message.'),
|
||||
);
|
||||
$form['message'] = array(
|
||||
];
|
||||
$form['message'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Message'),
|
||||
'#default_value' => $this->configuration['message'],
|
||||
'#cols' => '80',
|
||||
'#rows' => '20',
|
||||
'#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
if (!$this->emailValidator->isValid($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) {
|
||||
// We want the literal %author placeholder to be emphasized in the error message.
|
||||
$form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
|
||||
$form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', ['%author' => '[node:author:mail]']));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,22 +103,22 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'url' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['url'] = array(
|
||||
$form['url'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL'),
|
||||
'#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', array('@url' => 'http://example.com')),
|
||||
'#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']),
|
||||
'#default_value' => $this->configuration['url'],
|
||||
'#required' => TRUE,
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,23 +84,23 @@ class MessageAction extends ConfigurableActionBase implements ContainerFactoryPl
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'message' => '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['message'] = array(
|
||||
$form['message'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Message'),
|
||||
'#default_value' => $this->configuration['message'],
|
||||
'#required' => TRUE,
|
||||
'#rows' => '8',
|
||||
'#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ class Action extends DrupalSqlBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
$fields = [
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
);
|
||||
];
|
||||
if ($this->getModuleSchemaVersion('system') >= 7000) {
|
||||
$fields['label'] = $this->t('Label of the action');
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\action\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Test behaviors when visiting the action listing page.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
class ActionListTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('action');
|
||||
|
||||
/**
|
||||
* Tests the behavior when there are no actions to list in the admin page.
|
||||
*/
|
||||
public function testEmptyActionList() {
|
||||
// Create a user with permission to view the actions administration pages.
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer actions']));
|
||||
|
||||
// Ensure the empty text appears on the action list page.
|
||||
/** @var $storage \Drupal\Core\Entity\EntityStorageInterface */
|
||||
$storage = $this->container->get('entity.manager')->getStorage('action');
|
||||
$actions = $storage->loadMultiple();
|
||||
$storage->delete($actions);
|
||||
$this->drupalGet('/admin/config/system/actions');
|
||||
$this->assertRaw('There is no Action yet.');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue