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