From 1455122f90d12ee877193cc4676889f0da68745c Mon Sep 17 00:00:00 2001
From: Dylan Donkersgoed <ddonkersgoed@echidna.ca>
Date: Tue, 26 Sep 2017 21:31:20 -0400
Subject: [PATCH] 2884334-1-reroll

---
 .../src/Plugin/RabbitHoleEntityPlugin/Media.php    |  4 +++-
 .../src/Plugin/RabbitHoleEntityPlugin/Taxonomy.php |  1 +
 src/BehaviorInvoker.php                            |  2 +-
 src/BehaviorSettingsManager.php                    |  3 +--
 src/FormManglerService.php                         | 24 +++++++++++++++-------
 .../RabbitHoleBehaviorPlugin/PageRedirect.php      | 12 +++++++----
 src/Plugin/RabbitHoleBehaviorPluginBase.php        | 10 +++++++--
 src/Plugin/RabbitHoleBehaviorPluginInterface.php   | 10 +++++++--
 src/Plugin/RabbitHoleEntityPluginBase.php          |  1 +
 src/Plugin/RabbitHoleEntityPluginInterface.php     |  1 +
 src/Plugin/RabbitHoleEntityPluginManager.php       | 17 +++++++++------
 src/Tests/RabbitHoleBehaviorSettingsTest.php       |  3 +--
 12 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/modules/rh_media/src/Plugin/RabbitHoleEntityPlugin/Media.php b/modules/rh_media/src/Plugin/RabbitHoleEntityPlugin/Media.php
index 0b596b7..d2848d2 100644
--- a/modules/rh_media/src/Plugin/RabbitHoleEntityPlugin/Media.php
+++ b/modules/rh_media/src/Plugin/RabbitHoleEntityPlugin/Media.php
@@ -13,4 +13,6 @@ use Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginBase;
  *   entityType = "media"
  * )
  */
-class Media extends RabbitHoleEntityPluginBase { }
+class Media extends RabbitHoleEntityPluginBase {
+
+}
diff --git a/modules/rh_taxonomy/src/Plugin/RabbitHoleEntityPlugin/Taxonomy.php b/modules/rh_taxonomy/src/Plugin/RabbitHoleEntityPlugin/Taxonomy.php
index 3913ea4..f8f7f68 100644
--- a/modules/rh_taxonomy/src/Plugin/RabbitHoleEntityPlugin/Taxonomy.php
+++ b/modules/rh_taxonomy/src/Plugin/RabbitHoleEntityPlugin/Taxonomy.php
@@ -33,4 +33,5 @@ class Taxonomy extends RabbitHoleEntityPluginBase {
       'taxonomy_vocabulary' => 'vocabulary',
     ];
   }
+
 }
diff --git a/src/BehaviorInvoker.php b/src/BehaviorInvoker.php
index d3fbe28..63ad8a2 100644
--- a/src/BehaviorInvoker.php
+++ b/src/BehaviorInvoker.php
@@ -170,7 +170,7 @@ class BehaviorInvoker implements BehaviorInvokerInterface {
 
     // We trigger the default bundle action under the following circumstances:
     $trigger_default_bundle_action =
-    // Bundle settings do not allow override
+    // Bundle settings do not allow override.
       !$config->get('allow_override')
     // Entity does not have rh_action field.
       || !$entity->hasField('rh_action')
diff --git a/src/BehaviorSettingsManager.php b/src/BehaviorSettingsManager.php
index a7d1e55..4496d1f 100644
--- a/src/BehaviorSettingsManager.php
+++ b/src/BehaviorSettingsManager.php
@@ -67,8 +67,7 @@ class BehaviorSettingsManager implements BehaviorSettingsManagerInterface {
   /**
    * {@inheritdoc}
    */
-  public function loadBehaviorSettingsAsEditableConfig($entity_type_id,
-    $entity_id, $is_bundle = FALSE) {
+  public function loadBehaviorSettingsAsEditableConfig($entity_type_id, $entity_id, $is_bundle = FALSE) {
 
     $actual = $this->configFactory->getEditable(
       'rabbit_hole.behavior_settings.'
diff --git a/src/FormManglerService.php b/src/FormManglerService.php
index d9cbb18..3c37e55 100644
--- a/src/FormManglerService.php
+++ b/src/FormManglerService.php
@@ -95,8 +95,13 @@ class FormManglerService {
    *    defined even in the case of bundles since it is used to determine bundle
    *    and entity type.
    */
-  private function addRabbitHoleOptionsToForm(array &$attach, $entity_type_id,
-    $entity, FormStateInterface $form_state, $form_id) {
+  private function addRabbitHoleOptionsToForm(
+    array &$attach,
+    $entity_type_id,
+    $entity,
+    FormStateInterface $form_state,
+    $form_id
+  ) {
 
     $entity_type = $this->entityTypeManager->getStorage($entity_type_id)
       ->getEntityType();
@@ -318,16 +323,21 @@ class FormManglerService {
    *   The form state.
    * @param string $form_id
    *   The form ID.
-   * @param \Drupal\Core\Entity\Entity|NULL $entity
+   * @param \Drupal\Core\Entity\Entity|null $entity
    *   The entity whose settings form we are displaying.
    * @param bool $entity_is_bundle
    *   Whether the entity is a bundle.
-   * @param \Drupal\Core\Config\ImmutableConfig|NULL $bundle_settings
+   * @param \Drupal\Core\Config\ImmutableConfig|null $bundle_settings
    *   The settings for this bundle.
    */
-  protected function populateExtraBehaviorSections(&$form, $form_state,
-    $form_id, Entity $entity = NULL, $entity_is_bundle = FALSE,
-    ImmutableConfig $bundle_settings = NULL) {
+  protected function populateExtraBehaviorSections(
+    &$form,
+    $form_state,
+    $form_id,
+    Entity $entity = NULL,
+    $entity_is_bundle = FALSE,
+    ImmutableConfig $bundle_settings = NULL
+  ) {
 
     foreach ($this->rhBehaviorPluginManager->getDefinitions() as $id => $def) {
       $this->rhBehaviorPluginManager
diff --git a/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php b/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php
index 85dd600..f1a106c 100644
--- a/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php
+++ b/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php
@@ -22,8 +22,6 @@ use Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginManager;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
-
-
 /**
  * Redirects to another page.
  *
@@ -220,8 +218,14 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase implements ContainerFact
   /**
    * {@inheritdoc}
    */
-  public function settingsForm(&$form, &$form_state, $form_id, Entity $entity = NULL,
-    $entity_is_bundle = FALSE, ImmutableConfig $bundle_settings = NULL) {
+  public function settingsForm(
+    &$form,
+    &$form_state,
+    $form_id,
+    Entity $entity = NULL,
+    $entity_is_bundle = FALSE,
+    ImmutableConfig $bundle_settings = NULL
+  ) {
 
     $redirect = NULL;
     $redirect_code = NULL;
diff --git a/src/Plugin/RabbitHoleBehaviorPluginBase.php b/src/Plugin/RabbitHoleBehaviorPluginBase.php
index fe57e3b..f4be3f5 100644
--- a/src/Plugin/RabbitHoleBehaviorPluginBase.php
+++ b/src/Plugin/RabbitHoleBehaviorPluginBase.php
@@ -21,8 +21,14 @@ abstract class RabbitHoleBehaviorPluginBase extends PluginBase implements Rabbit
   /**
    * {@inheritdoc}
    */
-  public function settingsForm(&$form, &$form_state, $form_id, Entity $entity = NULL,
-    $entity_is_bundle = FALSE, ImmutableConfig $bundle_settings = NULL) {
+  public function settingsForm(
+    &$form,
+    &$form_state,
+    $form_id,
+    Entity $entity = NULL,
+    $entity_is_bundle = FALSE,
+    ImmutableConfig $bundle_settings = NULL
+  ) {
     // Present no settings form.
   }
 
diff --git a/src/Plugin/RabbitHoleBehaviorPluginInterface.php b/src/Plugin/RabbitHoleBehaviorPluginInterface.php
index f893e91..cad316f 100644
--- a/src/Plugin/RabbitHoleBehaviorPluginInterface.php
+++ b/src/Plugin/RabbitHoleBehaviorPluginInterface.php
@@ -40,8 +40,14 @@ interface RabbitHoleBehaviorPluginInterface extends PluginInspectionInterface {
    *   The behavior settings for the bundle of the entity (or the entity itself,
    *   if it is a bundle).
    */
-  public function settingsForm(&$form, &$form_state, $form_id, Entity $entity = NULL,
-    $entity_is_bundle = FALSE, ImmutableConfig $bundle_settings = NULL);
+  public function settingsForm(
+    &$form,
+    &$form_state,
+    $form_id,
+    Entity $entity = NULL,
+    $entity_is_bundle = FALSE,
+    ImmutableConfig $bundle_settings = NULL
+  );
 
   /**
    * Handle submission of the settings form for this plugin.
diff --git a/src/Plugin/RabbitHoleEntityPluginBase.php b/src/Plugin/RabbitHoleEntityPluginBase.php
index ff5c5aa..db4a729 100644
--- a/src/Plugin/RabbitHoleEntityPluginBase.php
+++ b/src/Plugin/RabbitHoleEntityPluginBase.php
@@ -52,4 +52,5 @@ abstract class RabbitHoleEntityPluginBase extends PluginBase implements RabbitHo
     }
     return $map;
   }
+
 }
diff --git a/src/Plugin/RabbitHoleEntityPluginInterface.php b/src/Plugin/RabbitHoleEntityPluginInterface.php
index a270676..d0d82c3 100644
--- a/src/Plugin/RabbitHoleEntityPluginInterface.php
+++ b/src/Plugin/RabbitHoleEntityPluginInterface.php
@@ -64,4 +64,5 @@ interface RabbitHoleEntityPluginInterface extends PluginInspectionInterface {
    *   ['entity ID' => 'token ID']
    */
   public function getEntityTokenMap();
+
 }
diff --git a/src/Plugin/RabbitHoleEntityPluginManager.php b/src/Plugin/RabbitHoleEntityPluginManager.php
index 8981f61..99a91d1 100644
--- a/src/Plugin/RabbitHoleEntityPluginManager.php
+++ b/src/Plugin/RabbitHoleEntityPluginManager.php
@@ -28,8 +28,12 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager {
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    *   The module handler to invoke the alter hook with.
    */
-  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler,
-    EntityTypeManagerInterface $etm) {
+  public function __construct(
+    \Traversable $namespaces,
+    CacheBackendInterface $cache_backend,
+    ModuleHandlerInterface $module_handler,
+    EntityTypeManagerInterface $etm
+  ) {
     parent::__construct('Plugin/RabbitHoleEntityPlugin', $namespaces, $module_handler, 'Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginInterface', 'Drupal\rabbit_hole\Annotation\RabbitHoleEntityPlugin');
 
     $this->alterInfo('rabbit_hole_rabbit_hole_entity_plugin_info');
@@ -65,7 +69,7 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager {
    *   An array of plugin definitions for the entity type with ID $entity_type.
    */
   public function loadDefinitionsByEntityType($entity_type) {
-    return array_filter($this->getDefinitions(), function($var) use ($entity_type) {
+    return array_filter($this->getDefinitions(), function ($var) use ($entity_type) {
       return $var['entityType'] == $entity_type;
     });
   }
@@ -77,7 +81,7 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager {
    *   An array of entity type ID strings.
    */
   public function loadSupportedEntityTypes() {
-    return array_values(array_map(function($var) {
+    return array_values(array_map(function ($var) {
       return $var['entityType'];
     }, $this->getDefinitions()));
   }
@@ -89,7 +93,7 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager {
    *   An array of entity type ID strings.
    */
   public function loadSupportedBundleEntityTypes() {
-    return array_values(array_map(function($var) {
+    return array_values(array_map(function ($var) {
       return $this->etm->getStorage($var['entityType'])
         ->getEntityType()->getBundleEntityType();
     }, $this->getDefinitions()));
@@ -117,8 +121,9 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager {
    * Load a map of tokens per entity type.
    *
    * Used for behavior plugins that use tokens like PageRedirect.
+   *
    * @return array
-   *  An array of token IDs keyed by entity ID
+   *   An array of token IDs keyed by entity ID
    */
   public function loadEntityTokenMap() {
     $map = [];
diff --git a/src/Tests/RabbitHoleBehaviorSettingsTest.php b/src/Tests/RabbitHoleBehaviorSettingsTest.php
index 74f9886..cbb0cbd 100644
--- a/src/Tests/RabbitHoleBehaviorSettingsTest.php
+++ b/src/Tests/RabbitHoleBehaviorSettingsTest.php
@@ -112,8 +112,7 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase {
   /**
    * Helper function to test saving and confirming config.
    */
-  private function saveAndTestExpectedValues($expected_action,
-    $calling_method, $entity_type_label = '', $entity_id = NULL) {
+  private function saveAndTestExpectedValues($expected_action, $calling_method, $entity_type_label = '', $entity_id = NULL) {
 
     // Delete key if it already exists.
     $editable = $this->behaviorSettingsManager->loadBehaviorSettingsAsEditableConfig(
-- 
2.7.4

