Commit d3118bdf authored by anon's avatar anon

by anon: Use short array syntax

parent b3838aee
......@@ -180,12 +180,12 @@ class EntityMatcher extends ConfigurableMatcherBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$entity_type = $this->entityTypeManager->getDefinition($this->targetType);
$form['metadata'] = array(
$form['metadata'] = [
'#type' => 'details',
'#title' => $this->t('Suggestion metadata'),
'#open' => TRUE,
'#weight' => -100,
);
];
$form['metadata']['metadata'] = [
'#title' => $this->t('Metadata'),
......@@ -206,12 +206,12 @@ class EntityMatcher extends ConfigurableMatcherBase {
$bundle_options[$bundle_name] = $bundle_info['label'];
}
$form['bundle_restrictions'] = array(
$form['bundle_restrictions'] = [
'#type' => 'details',
'#title' => $this->t('Bundle restrictions'),
'#open' => TRUE,
'#weight' => -90,
);
];
$form['bundle_restrictions']['bundles'] = [
'#type' => 'checkboxes',
......@@ -222,11 +222,11 @@ class EntityMatcher extends ConfigurableMatcherBase {
'#element_validate' => [[get_class($this), 'elementValidateFilter']],
];
$form['bundle_grouping'] = array(
$form['bundle_grouping'] = [
'#type' => 'details',
'#title' => $this->t('Bundle grouping'),
'#open' => TRUE,
);
];
// Group the suggestions by bundle.
$form['bundle_grouping']['group_by_bundle'] = [
......@@ -238,13 +238,13 @@ class EntityMatcher extends ConfigurableMatcherBase {
}
$substitution_options = $this->substitutionManager->getApplicablePluginsOptionList($this->targetType);
$form['substitution'] = array(
$form['substitution'] = [
'#type' => 'details',
'#title' => $this->t('URL substitution'),
'#open' => TRUE,
'#weight' => 100,
'#access' => count($substitution_options) !== 1,
);
];
$form['substitution']['substitution_type'] = [
'#title' => $this->t('Substitution Type'),
'#type' => 'select',
......
......@@ -89,12 +89,12 @@ class FileMatcher extends EntityMatcher {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['extensions'] = array(
$form['extensions'] = [
'#type' => 'details',
'#title' => $this->t('File extensions'),
'#open' => TRUE,
'#weight' => -100,
);
];
$file_extensions = str_replace(' ', ', ', $this->configuration['file_extensions']);
$form['extensions']['file_extensions'] = [
......
......@@ -53,11 +53,11 @@ class NodeMatcher extends EntityMatcher {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['unpublished_nodes'] = array(
$form['unpublished_nodes'] = [
'#type' => 'details',
'#title' => $this->t('Unpublished nodes'),
'#open' => TRUE,
);
];
$form['unpublished_nodes']['include_unpublished'] = [
'#title' => $this->t('Include unpublished nodes'),
......
......@@ -60,12 +60,12 @@ class UserMatcher extends EntityMatcher {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['role_restrictions'] = array(
$form['role_restrictions'] = [
'#type' => 'details',
'#title' => $this->t('Role restrictions'),
'#open' => TRUE,
'#weight' => -90,
);
];
$form['role_restrictions']['roles'] = [
'#type' => 'checkboxes',
......@@ -76,11 +76,11 @@ class UserMatcher extends EntityMatcher {
'#element_validate' => [[get_class($this), 'elementValidateFilter']],
];
$form['blocked_users'] = array(
$form['blocked_users'] = [
'#type' => 'details',
'#title' => $this->t('Blocked users'),
'#open' => TRUE,
);
];
$form['blocked_users']['include_blocked'] = [
'#title' => $this->t('Include blocked user'),
......
......@@ -30,7 +30,7 @@ class LinkitDialogTest extends JavascriptTestBase {
/**
* An instance of the "CKEditor" text editor plugin.
*
* @var \Drupal\ckeditor\Plugin\Editor\CKEditor;
* @var \Drupal\ckeditor\Plugin\Editor\CKEditor
*/
protected $ckeditor;
......
......@@ -111,13 +111,13 @@ class LinkitFilterEntityTest extends LinkitKernelTestBase {
* Tests the linkit filter for file entities.
*/
public function testFilterFileEntity() {
$file = File::create(array(
$file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
));
]);
$file->save();
// Disable the automatic title attribute.
......
......@@ -47,22 +47,22 @@ abstract class LinkitKernelTestBase extends KernelTestBase {
* @return \Drupal\user\Entity\User
* The created user entity.
*/
protected function createUser($values = array(), $permissions = array()) {
protected function createUser(array $values = [], array $permissions = []) {
if ($permissions) {
// Create a new role and apply permissions to it.
$role = Role::create(array(
$role = Role::create([
'id' => strtolower($this->randomMachineName(8)),
'label' => $this->randomMachineName(8),
));
]);
$role->save();
user_role_grant_permissions($role->id(), $permissions);
$values['roles'][] = $role->id();
}
$account = User::create($values + array(
$account = User::create($values + [
'name' => $this->randomMachineName(),
'status' => 1,
));
]);
$account->enforceIsNew();
$account->save();
return $account;
......
......@@ -34,7 +34,7 @@ class FileMatcherTest extends LinkitKernelTestBase {
$this->installEntitySchema('file');
$this->installSchema('system', ['key_value_expire']);
$this->installSchema('file', array('file_usage'));
$this->installSchema('file', ['file_usage']);
$this->manager = $this->container->get('plugin.manager.linkit.matcher');
......
......@@ -42,44 +42,44 @@ class NodeMatcherTest extends LinkitKernelTestBase {
// anonymous user.
\Drupal::currentUser()->setAccount($this->createUser());
$type1 = NodeType::create(array(
$type1 = NodeType::create([
'type' => 'test1',
'name' => 'Test1',
));
]);
$type1->save();
$type2 = NodeType::create(array(
$type2 = NodeType::create([
'type' => 'test2',
'name' => 'Test2',
));
]);
$type2->save();
// Nodes with type 1.
$node = Node::create(array(
$node = Node::create([
'title' => 'Lorem Ipsum 1',
'type' => $type1->id(),
));
]);
$node->save();
$node = Node::create(array(
$node = Node::create([
'title' => 'Lorem Ipsum 2',
'type' => $type1->id(),
));
]);
$node->save();
// Node with type 2.
$node = Node::create(array(
$node = Node::create([
'title' => 'Lorem Ipsum 3',
'type' => $type2->id(),
));
]);
$node->save();
// Unpublished node.
$node = Node::create(array(
$node = Node::create([
'title' => 'Lorem unpublishd',
'type' => $type1->id(),
'status' => FALSE,
));
]);
$node->save();
// Set the current user to someone that is not the node owner.
......
......@@ -105,7 +105,7 @@ class TermMatcherTest extends LinkitKernelTestBase {
* @param string $name
* The vocabulary name.
*
* @return VocabularyInterface The new vocabulary object.
* @return \Drupal\Core\Entity\EntityInterface|\Drupal\taxonomy\VocabularyInterface
* The new vocabulary object.
*/
private function createVocabulary($name) {
......@@ -132,7 +132,7 @@ class TermMatcherTest extends LinkitKernelTestBase {
* @return \Drupal\taxonomy\Entity\Term
* The new taxonomy term object.
*/
private function createTerm(VocabularyInterface $vocabulary, $values = []) {
private function createTerm(VocabularyInterface $vocabulary, array $values = []) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
......
......@@ -27,16 +27,16 @@ class UserMatcherTest extends LinkitKernelTestBase {
$this->manager = $this->container->get('plugin.manager.linkit.matcher');
$custom_role = Role::create(array(
$custom_role = Role::create([
'id' => 'custom_role',
'label' => 'custom_role',
));
]);
$custom_role->save();
$custom_role_admin = Role::create(array(
$custom_role_admin = Role::create([
'id' => 'custom_role_admin',
'label' => 'custom_role_admin',
));
]);
$custom_role_admin->save();
$this->createUser(['name' => 'lorem']);
......
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