Commit 03f12573 authored by anon's avatar anon

by anon: Use shorthand array syntax.

parent 38149d64
...@@ -64,11 +64,11 @@ function linkit_form_editor_link_dialog_alter(&$form, FormStateInterface $form_s ...@@ -64,11 +64,11 @@ function linkit_form_editor_link_dialog_alter(&$form, FormStateInterface $form_s
'#url' => Url::fromRoute('imce.page', [ '#url' => Url::fromRoute('imce.page', [
'scheme' => $linkit_profile->getThirdPartySetting('imce', 'scheme', 'public'), 'scheme' => $linkit_profile->getThirdPartySetting('imce', 'scheme', 'public'),
]), ]),
'#options' => array( '#options' => [
'query' => array( 'query' => [
'sendto' => 'linkitImce.sendto', 'sendto' => 'linkitImce.sendto',
), ],
), ],
'#attributes' => [ '#attributes' => [
'class' => ['linkit-imce-open'], 'class' => ['linkit-imce-open'],
], ],
......
...@@ -20,7 +20,7 @@ class LinkitController extends ControllerBase { ...@@ -20,7 +20,7 @@ class LinkitController extends ControllerBase {
* The profile label as a render array. * The profile label as a render array.
*/ */
public function profileTitle(ProfileInterface $linkit_profile) { public function profileTitle(ProfileInterface $linkit_profile) {
return $this->t('Edit %label profile', array('%label' => $linkit_profile->label())); return $this->t('Edit %label profile', ['%label' => $linkit_profile->label()]);
} }
/** /**
...@@ -37,7 +37,7 @@ class LinkitController extends ControllerBase { ...@@ -37,7 +37,7 @@ class LinkitController extends ControllerBase {
public function matcherTitle(ProfileInterface $linkit_profile, $plugin_instance_id) { public function matcherTitle(ProfileInterface $linkit_profile, $plugin_instance_id) {
/** @var \Drupal\linkit\MatcherInterface $matcher */ /** @var \Drupal\linkit\MatcherInterface $matcher */
$matcher = $linkit_profile->getMatcher($plugin_instance_id); $matcher = $linkit_profile->getMatcher($plugin_instance_id);
return $this->t('Edit %label matcher', array('%label' => $matcher->getLabel())); return $this->t('Edit %label matcher', ['%label' => $matcher->getLabel()]);
} }
} }
...@@ -21,20 +21,20 @@ class Linkit extends FormElement { ...@@ -21,20 +21,20 @@ class Linkit extends FormElement {
*/ */
public function getInfo() { public function getInfo() {
$class = get_class($this); $class = get_class($this);
return array( return [
'#input' => TRUE, '#input' => TRUE,
'#size' => 60, '#size' => 60,
'#process' => array( '#process' => [
array($class, 'processLinkitAutocomplete'), [$class, 'processLinkitAutocomplete'],
array($class, 'processGroup'), [$class, 'processGroup'],
), ],
'#pre_render' => array( '#pre_render' => [
array($class, 'preRenderLinkitElement'), [$class, 'preRenderLinkitElement'],
array($class, 'preRenderGroup'), [$class, 'preRenderGroup'],
), ],
'#theme' => 'input__textfield', '#theme' => 'input__textfield',
'#theme_wrappers' => array('form_element'), '#theme_wrappers' => ['form_element'],
); ];
} }
/** /**
...@@ -58,7 +58,7 @@ class Linkit extends FormElement { ...@@ -58,7 +58,7 @@ class Linkit extends FormElement {
$access = FALSE; $access = FALSE;
if (!empty($element['#autocomplete_route_name'])) { if (!empty($element['#autocomplete_route_name'])) {
$parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : array(); $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : [];
$url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE); $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE);
/** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */ /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */
$access_manager = \Drupal::service('access_manager'); $access_manager = \Drupal::service('access_manager');
...@@ -94,8 +94,8 @@ class Linkit extends FormElement { ...@@ -94,8 +94,8 @@ class Linkit extends FormElement {
*/ */
public static function preRenderLinkitElement($element) { public static function preRenderLinkitElement($element) {
$element['#attributes']['type'] = 'text'; $element['#attributes']['type'] = 'text';
Element::setAttributes($element, array('id', 'name', 'value', 'size')); Element::setAttributes($element, ['id', 'name', 'value', 'size']);
static::setAttributes($element, array('form-text')); static::setAttributes($element, ['form-text']);
return $element; return $element;
} }
......
...@@ -43,14 +43,14 @@ class EditForm extends FormBase { ...@@ -43,14 +43,14 @@ class EditForm extends FormBase {
$form += $this->linkitMatcher->buildConfigurationForm($form, $form_state); $form += $this->linkitMatcher->buildConfigurationForm($form, $form_state);
$form['actions'] = array('#type' => 'actions'); $form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = array( $form['actions']['submit'] = [
'#type' => 'submit', '#type' => 'submit',
'#value' => $this->t('Save changes'), '#value' => $this->t('Save changes'),
'#submit' => array('::submitForm'), '#submit' => ['::submitForm'],
'#button_type' => 'primary', '#button_type' => 'primary',
); ];
$form['actions']['delete'] = array( $form['actions']['delete'] = [
'#type' => 'link', '#type' => 'link',
'#title' => $this->t('Delete'), '#title' => $this->t('Delete'),
'#url' => Url::fromRoute('linkit.matcher.delete', [ '#url' => Url::fromRoute('linkit.matcher.delete', [
...@@ -60,7 +60,7 @@ class EditForm extends FormBase { ...@@ -60,7 +60,7 @@ class EditForm extends FormBase {
'#attributes' => [ '#attributes' => [
'class' => ['button', 'button--danger'], 'class' => ['button', 'button--danger'],
], ],
); ];
return $form; return $form;
} }
...@@ -74,7 +74,7 @@ class EditForm extends FormBase { ...@@ -74,7 +74,7 @@ class EditForm extends FormBase {
$this->linkitMatcher->submitConfigurationForm($form, $plugin_data); $this->linkitMatcher->submitConfigurationForm($form, $plugin_data);
$this->linkitProfile->save(); $this->linkitProfile->save();
drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->linkitMatcher->getLabel()))); drupal_set_message($this->t('Saved %label configuration.', ['%label' => $this->linkitMatcher->getLabel()]));
$this->logger('linkit')->notice('The matcher %label has been updated in the @profile profile.', [ $this->logger('linkit')->notice('The matcher %label has been updated in the @profile profile.', [
'%label' => $this->linkitMatcher->getLabel(), '%label' => $this->linkitMatcher->getLabel(),
'@profile' => $this->linkitProfile->label(), '@profile' => $this->linkitProfile->label(),
......
...@@ -53,20 +53,20 @@ abstract class FormBase extends EntityForm { ...@@ -53,20 +53,20 @@ abstract class FormBase extends EntityForm {
]; ];
if ($this->moduleHandler->moduleExists('imce')) { if ($this->moduleHandler->moduleExists('imce')) {
$form['imce'] = array( $form['imce'] = [
'#type' => 'details', '#type' => 'details',
'#title' => t('IMCE integration'), '#title' => t('IMCE integration'),
'#group' => 'additional_settings', '#group' => 'additional_settings',
); ];
$form['imce']['imce_use'] = array( $form['imce']['imce_use'] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Enable IMCE File Browser in the editor dialog.'), '#title' => t('Enable IMCE File Browser in the editor dialog.'),
'#default_value' => $this->entity->getThirdPartySetting('imce', 'use', FALSE), '#default_value' => $this->entity->getThirdPartySetting('imce', 'use', FALSE),
); ];
$scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::READ_VISIBLE); $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::READ_VISIBLE);
$form['imce']['imce_scheme'] = array( $form['imce']['imce_scheme'] = [
'#type' => 'radios', '#type' => 'radios',
'#title' => t('Scheme'), '#title' => t('Scheme'),
'#options' => $scheme_options, '#options' => $scheme_options,
...@@ -76,7 +76,7 @@ abstract class FormBase extends EntityForm { ...@@ -76,7 +76,7 @@ abstract class FormBase extends EntityForm {
':input[name="imce_use"]' => ['checked' => TRUE], ':input[name="imce_use"]' => ['checked' => TRUE],
], ],
], ],
); ];
} }
return parent::form($form, $form_state); return parent::form($form, $form_state);
......
...@@ -53,7 +53,7 @@ abstract class MatcherBase extends PluginBase implements MatcherInterface, Conta ...@@ -53,7 +53,7 @@ abstract class MatcherBase extends PluginBase implements MatcherInterface, Conta
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSummary() { public function getSummary() {
return array(); return [];
} }
/** /**
......
...@@ -15,18 +15,18 @@ trait MatcherTokensTrait { ...@@ -15,18 +15,18 @@ trait MatcherTokensTrait {
* @param array $types * @param array $types
* An array of token types to use. * An array of token types to use.
*/ */
public function insertTokenList(&$form, array $types = array()) { public function insertTokenList(&$form, array $types = []) {
if (\Drupal::moduleHandler()->moduleExists('token')) { if (\Drupal::moduleHandler()->moduleExists('token')) {
// Add the token tree UI. // Add the token tree UI.
$form['token_tree'] = array( $form['token_tree'] = [
'#theme' => 'token_tree_link', '#theme' => 'token_tree_link',
'#token_types' => $types, '#token_types' => $types,
'#dialog' => TRUE, '#dialog' => TRUE,
'#weight' => -90, '#weight' => -90,
); ];
} }
else { else {
$token_items = array(); $token_items = [];
foreach ($this->getAvailableTokens($types) as $type => $tokens) { foreach ($this->getAvailableTokens($types) as $type => $tokens) {
foreach ($tokens as $name => $info) { foreach ($tokens as $name => $info) {
$token_description = !empty($info['description']) ? $info['description'] : ''; $token_description = !empty($info['description']) ? $info['description'] : '';
...@@ -35,16 +35,16 @@ trait MatcherTokensTrait { ...@@ -35,16 +35,16 @@ trait MatcherTokensTrait {
} }
if (count($token_items)) { if (count($token_items)) {
$form['tokens'] = array( $form['tokens'] = [
'#type' => 'details', '#type' => 'details',
'#title' => t('Available tokens'), '#title' => t('Available tokens'),
'#weight' => -90, '#weight' => -90,
); ];
$form['tokens']['list'] = array( $form['tokens']['list'] = [
'#theme' => 'item_list', '#theme' => 'item_list',
'#items' => $token_items, '#items' => $token_items,
); ];
} }
} }
} }
...@@ -58,7 +58,7 @@ trait MatcherTokensTrait { ...@@ -58,7 +58,7 @@ trait MatcherTokensTrait {
* @return array * @return array
* An array with available tokens * An array with available tokens
*/ */
public function getAvailableTokens(array $types = array()) { public function getAvailableTokens(array $types = []) {
$info = \Drupal::token()->getInfo(); $info = \Drupal::token()->getInfo();
$available = array_intersect_key($info['tokens'], array_flip($types)); $available = array_intersect_key($info['tokens'], array_flip($types));
return $available; return $available;
......
...@@ -80,12 +80,12 @@ class FileMatcher extends EntityMatcher { ...@@ -80,12 +80,12 @@ class FileMatcher extends EntityMatcher {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['images'] = array( $form['images'] = [
'#type' => 'details', '#type' => 'details',
'#title' => t('Image file settings'), '#title' => t('Image file settings'),
'#description' => t('Extra settings for image files in the result.'), '#description' => t('Extra settings for image files in the result.'),
'#tree' => TRUE, '#tree' => TRUE,
); ];
$form['images']['show_dimensions'] = [ $form['images']['show_dimensions'] = [
'#title' => t('Show pixel dimensions'), '#title' => t('Show pixel dimensions'),
...@@ -144,7 +144,7 @@ class FileMatcher extends EntityMatcher { ...@@ -144,7 +144,7 @@ class FileMatcher extends EntityMatcher {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function buildDescription(EntityInterface $entity) { protected function buildDescription(EntityInterface $entity) {
$description_array = array(); $description_array = [];
$description_array[] = parent::buildDescription($entity); $description_array[] = parent::buildDescription($entity);
...@@ -159,12 +159,12 @@ class FileMatcher extends EntityMatcher { ...@@ -159,12 +159,12 @@ class FileMatcher extends EntityMatcher {
} }
if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) { if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) {
$image_element = array( $image_element = [
'#weight' => -10, '#weight' => -10,
'#theme' => 'image_style', '#theme' => 'image_style',
'#style_name' => $this->configuration['images']['thumbnail_image_style'], '#style_name' => $this->configuration['images']['thumbnail_image_style'],
'#uri' => $entity->getFileUri(), '#uri' => $entity->getFileUri(),
); ];
$description_array[] = (string) \Drupal::service('renderer')->render($image_element); $description_array[] = (string) \Drupal::service('renderer')->render($image_element);
} }
......
...@@ -60,14 +60,14 @@ class UserMatcher extends EntityMatcher { ...@@ -60,14 +60,14 @@ class UserMatcher extends EntityMatcher {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['roles'] = array( $form['roles'] = [
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => $this->t('Restrict to the selected roles'), '#title' => $this->t('Restrict to the selected roles'),
'#options' => array_diff_key(user_role_names(TRUE), array(RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID)), '#options' => array_diff_key(user_role_names(TRUE), [RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID]),
'#default_value' => $this->configuration['roles'], '#default_value' => $this->configuration['roles'],
'#description' => $this->t('If none of the checkboxes is checked, allow all roles.'), '#description' => $this->t('If none of the checkboxes is checked, allow all roles.'),
'#element_validate' => [[get_class($this), 'elementValidateFilter']], '#element_validate' => [[get_class($this), 'elementValidateFilter']],
); ];
$form['include_blocked'] = [ $form['include_blocked'] = [
'#title' => t('Include blocked user'), '#title' => t('Include blocked user'),
......
...@@ -22,7 +22,7 @@ class ResultManager { ...@@ -22,7 +22,7 @@ class ResultManager {
* An array of matches. * An array of matches.
*/ */
public function getResults(ProfileInterface $linkitProfile, $search_string) { public function getResults(ProfileInterface $linkitProfile, $search_string) {
$matches = array(); $matches = [];
if (empty(trim($search_string))) { if (empty(trim($search_string))) {
return [ return [
......
...@@ -27,7 +27,7 @@ abstract class LinkitFilterTestBase extends LinkitTestBase { ...@@ -27,7 +27,7 @@ abstract class LinkitFilterTestBase extends LinkitTestBase {
/** @var \Drupal\Component\Plugin\PluginManagerInterface $manager */ /** @var \Drupal\Component\Plugin\PluginManagerInterface $manager */
$manager = $this->container->get('plugin.manager.filter'); $manager = $this->container->get('plugin.manager.filter');
$bag = new FilterPluginCollection($manager, array()); $bag = new FilterPluginCollection($manager, []);
$this->filter = $bag->get('linkit'); $this->filter = $bag->get('linkit');
} }
......
...@@ -59,7 +59,7 @@ class MatcherCrudTest extends LinkitTestBase { ...@@ -59,7 +59,7 @@ class MatcherCrudTest extends LinkitTestBase {
'linkit_profile' => $this->linkitProfile->id(), 'linkit_profile' => $this->linkitProfile->id(),
])); ]));
$edit = array(); $edit = [];
$edit['plugin'] = 'dummy_matcher'; $edit['plugin'] = 'dummy_matcher';
$this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->drupalPostForm(NULL, $edit, t('Save and continue'));
...@@ -82,7 +82,7 @@ class MatcherCrudTest extends LinkitTestBase { ...@@ -82,7 +82,7 @@ class MatcherCrudTest extends LinkitTestBase {
'linkit_profile' => $this->linkitProfile->id(), 'linkit_profile' => $this->linkitProfile->id(),
])); ]));
$edit = array(); $edit = [];
$edit['plugin'] = 'configurable_dummy_matcher'; $edit['plugin'] = 'configurable_dummy_matcher';
$this->drupalPostForm(NULL, $edit, t('Save and continue')); $this->drupalPostForm(NULL, $edit, t('Save and continue'));
......
...@@ -61,21 +61,21 @@ class TermMatcherTest extends LinkitTestBase { ...@@ -61,21 +61,21 @@ class TermMatcherTest extends LinkitTestBase {
* @return \Drupal\taxonomy\Entity\Term * @return \Drupal\taxonomy\Entity\Term
* The new taxonomy term object. * The new taxonomy term object.
*/ */
private function createTerm(Vocabulary $vocabulary, $values = array()) { private function createTerm(Vocabulary $vocabulary, $values = []) {
$filter_formats = filter_formats(); $filter_formats = filter_formats();
$format = array_pop($filter_formats); $format = array_pop($filter_formats);
$termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$term = $termStorage->create($values + array( $term = $termStorage->create($values + [
'name' => $this->randomMachineName(), 'name' => $this->randomMachineName(),
'description' => array( 'description' => [
'value' => $this->randomMachineName(), 'value' => $this->randomMachineName(),
// Use the first available text format. // Use the first available text format.
'format' => $format->id(), 'format' => $format->id(),
), ],
'vid' => $vocabulary->id(), 'vid' => $vocabulary->id(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ]);
$term->save(); $term->save();
return $term; return $term;
} }
......
...@@ -33,8 +33,8 @@ class UserMatcherTest extends LinkitTestBase { ...@@ -33,8 +33,8 @@ class UserMatcherTest extends LinkitTestBase {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->manager = $this->container->get('plugin.manager.linkit.matcher'); $this->manager = $this->container->get('plugin.manager.linkit.matcher');
$custom_role = $this->drupalCreateRole(array(), 'custom_role', 'custom_role'); $custom_role = $this->drupalCreateRole([], 'custom_role', 'custom_role');
$custom_role_admin = $this->drupalCreateRole(array(), 'custom_role_admin', 'custom_role_admin'); $custom_role_admin = $this->drupalCreateRole([], 'custom_role_admin', 'custom_role_admin');
$this->drupalCreateUser([], 'lorem'); $this->drupalCreateUser([], 'lorem');
$this->drupalCreateUser([], 'foo'); $this->drupalCreateUser([], 'foo');
......
...@@ -16,16 +16,16 @@ $connection = Database::getConnection(); ...@@ -16,16 +16,16 @@ $connection = Database::getConnection();
// Configuration for linkit profiles. // Configuration for linkit profiles.
$config = Yaml::decode(file_get_contents(__DIR__ . '/linkit.linkit_profile.test_profile.yml')); $config = Yaml::decode(file_get_contents(__DIR__ . '/linkit.linkit_profile.test_profile.yml'));
$connection->insert('config') $connection->insert('config')
->fields(array( ->fields([
'collection', 'collection',
'name', 'name',
'data', 'data',
)) ])
->values(array( ->values([
'collection' => '', 'collection' => '',
'name' => 'linkit.linkit_profile.' . $config['id'], 'name' => 'linkit.linkit_profile.' . $config['id'],
'data' => serialize($config), 'data' => serialize($config),
)) ])
->execute(); ->execute();
...@@ -36,16 +36,16 @@ $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/filter.format.format_2.y ...@@ -36,16 +36,16 @@ $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/filter.format.format_2.y
$configs[] = Yaml::decode(file_get_contents(__DIR__ . '/filter.format.format_3.yml')); $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/filter.format.format_3.yml'));
foreach ($configs as $config) { foreach ($configs as $config) {
$connection->insert('config') $connection->insert('config')
->fields(array( ->fields([
'collection', 'collection',
'name', 'name',
'data', 'data',
)) ])
->values(array( ->values([
'collection' => '', 'collection' => '',
'name' => 'filter.format.' . $config['format'], 'name' => 'filter.format.' . $config['format'],
'data' => serialize($config), 'data' => serialize($config),
)) ])
->execute(); ->execute();
} }
...@@ -56,15 +56,15 @@ $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/editor.editor.format_2.y ...@@ -56,15 +56,15 @@ $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/editor.editor.format_2.y
$configs[] = Yaml::decode(file_get_contents(__DIR__ . '/editor.editor.format_3.yml')); $configs[] = Yaml::decode(file_get_contents(__DIR__ . '/editor.editor.format_3.yml'));
foreach ($configs as $config) { foreach ($configs as $config) {
$connection->insert('config') $connection->insert('config')
->fields(array( ->fields([
'collection', 'collection',
'name', 'name',
'data', 'data',
)) ])
->values(array( ->values([
'collection' => '', 'collection' => '',
'name' => 'editor.editor.' . $config['format'], 'name' => 'editor.editor.' . $config['format'],
'data' => serialize($config), 'data' => serialize($config),
)) ])
->execute(); ->execute();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment