diff --git a/addanother.info.yml b/addanother.info.yml index 8f3b2a2..c7d62dd 100644 --- a/addanother.info.yml +++ b/addanother.info.yml @@ -3,5 +3,4 @@ description: Presents users with an option to create another node of the same ty type: module core: 8.x package: User interface -version: 8.x-1.x configure: addanother.admin_config diff --git a/addanother.links.menu.yml b/addanother.links.menu.yml index a198dff..9427f8a 100644 --- a/addanother.links.menu.yml +++ b/addanother.links.menu.yml @@ -2,4 +2,4 @@ addanother.admin_config: title: 'Add another settings' description: 'Default Add another settings for new content types. Add another can be configured on existing content types by editing the content type.' route_name: addanother.admin_config - parent: 'system.admin_config_content' \ No newline at end of file + parent: 'system.admin_config_content' diff --git a/addanother.links.task.yml b/addanother.links.task.yml index e639fc2..b5622a4 100644 --- a/addanother.links.task.yml +++ b/addanother.links.task.yml @@ -7,4 +7,4 @@ addanother.admin_config: title: 'Settings' route_name: addanother.admin_config base_route: addanother.admin_config - weight: 0 \ No newline at end of file + weight: 0 diff --git a/addanother.module b/addanother.module index b6b5a9e..aa4b584 100644 --- a/addanother.module +++ b/addanother.module @@ -131,7 +131,7 @@ function addanother_node_form_submit($form, FormStateInterface &$form_state) { /* @var \Drupal\node\NodeInterface $node */ if ($node = $form_state->getFormObject()->getEntity()) { $type = $node->getType(); - $form_state->setRedirect('node.add', array('node_type' => $type)); + $form_state->setRedirect('node.add', ['node_type' => $type]); _addanother_quelch_message($node); $t_args = [ '@type' => node_get_type_label($node), @@ -165,7 +165,7 @@ function addanother_node_form_message_submit($form, FormStateInterface &$form_st /** * Remove the default Drupal node creation message. * - * @param $node \Drupal\node\NodeInterface; + * @param \Drupal\node\NodeInterface $node * Node entity. * * @return bool diff --git a/src/Form/AddAnotherSettingsForm.php b/src/Form/AddAnotherSettingsForm.php index c4bc176..fc59bb5 100644 --- a/src/Form/AddAnotherSettingsForm.php +++ b/src/Form/AddAnotherSettingsForm.php @@ -30,30 +30,30 @@ class AddAnotherSettingsForm extends ConfigFormBase { public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('addanother.settings'); - $form['addanother_display'] = array( + $form['addanother_display'] = [ '#type' => 'fieldset', '#title' => $this->t('Default settings for newly created content types'), - ); - $form['addanother_display']['default_button'] = array( + ]; + $form['addanother_display']['default_button'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Display Add another button on node add form for new content types.'), '#default_value' => $config->get('default_button'), - ); - $form['addanother_display']['default_message'] = array( + ]; + $form['addanother_display']['default_message'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Display the Add another message after node creation for new content types.'), '#default_value' => $config->get('default_message'), - ); - $form['addanother_display']['default_tab'] = array( + ]; + $form['addanother_display']['default_tab'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Display the Add another tab for new content types.'), '#default_value' => $config->get('default_tab'), - ); - $form['addanother_display']['default_tab_edit'] = array( + ]; + $form['addanother_display']['default_tab_edit'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Also display the Add another tab on edit page for new content types.'), '#default_value' => $config->get('default_tab_edit'), - ); + ]; return parent::buildForm($form, $form_state); } diff --git a/src/Tests/AddAnotherTest.php b/src/Tests/AddAnotherTest.php index ef1c614..47d534e 100644 --- a/src/Tests/AddAnotherTest.php +++ b/src/Tests/AddAnotherTest.php @@ -16,7 +16,7 @@ class AddAnotherTest extends WebTestBase { * * @var array */ - static public $modules = array('addanother'); + static public $modules = ['addanother']; /** * The installation profile to use with this test. @@ -41,36 +41,36 @@ class AddAnotherTest extends WebTestBase { ->set('tab_edit.' . $node_type, TRUE) ->save(); - $settings = array( + $settings = [ 'type' => $node_type, 'name' => $node_type, - ); + ]; $this->drupalCreateContentType($settings); - $web_user = $this->drupalCreateUser(array( + $web_user = $this->drupalCreateUser([ 'bypass node access', 'administer content types', 'use add another', 'administer add another', - )); + ]); $this->drupalLogin($web_user); // Create a node. - $edit = array(); + $edit = []; $edit['title[0][value]'] = $this->randomMachineName(8); $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm("node/add/$node_type", $edit, t('Save')); // Check that the node has been created. - $this->assertText(t('@post @title has been created.', array( + $this->assertText(t('@post @title has been created.', [ '@post' => $node_type, '@title' => $edit['title[0][value]'], - )), 'Node created.'); - $this->assertText(t('You may add another @type.', array('@type' => $node_type)), 'Addanother message was presented.'); + ]), 'Node created.'); + $this->assertText(t('You may add another @type.', ['@type' => $node_type]), 'Addanother message was presented.'); $this->assertLink('Add another'); // Create a node. - $edit = array(); + $edit = []; $edit['title[0][value]'] = $this->randomMachineName(8); $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm("node/add/$node_type", $edit, t('Save and add another'));