diff --git a/modules/rh_node/rh-node.js b/modules/rh_node/rh-node.js index 36dceea..c9448e7 100644 --- a/modules/rh_node/rh-node.js +++ b/modules/rh_node/rh-node.js @@ -1,18 +1,22 @@ +/** + * @file + */ + (function($) { -Drupal.behaviors.rhNode = { - attach: function (context, settings) { + Drupal.behaviors.rhNode = { + attach: function (context, settings) { - // Set the summary for the settings form. - $('fieldset.rabbit-hole-settings-form').drupalSetSummary(function() { - var $rabbitHoleAction = $('.rabbit-hole-action-setting input:checked'); + // Set the summary for the settings form. + $('fieldset.rabbit-hole-settings-form').drupalSetSummary(function() { + var $rabbitHoleAction = $('.rabbit-hole-action-setting input:checked'); - // Get the label of the selected action. - var summary = $('label[for=' + $rabbitHoleAction.attr('id') + ']').text(); - return Drupal.checkPlain(summary); - }); + // Get the label of the selected action. + var summary = $('label[for=' + $rabbitHoleAction.attr('id') + ']').text(); + return Drupal.checkPlain(summary); + }); + } } -} })(jQuery); diff --git a/modules/rh_node/src/Plugin/RabbitHoleEntityPlugin/Node.php b/modules/rh_node/src/Plugin/RabbitHoleEntityPlugin/Node.php index 810474a..d14276c 100644 --- a/modules/rh_node/src/Plugin/RabbitHoleEntityPlugin/Node.php +++ b/modules/rh_node/src/Plugin/RabbitHoleEntityPlugin/Node.php @@ -29,4 +29,5 @@ class Node extends RabbitHoleEntityPluginBase { array('actions', 'publish', '#submit'), ); } + } diff --git a/modules/rh_node/src/Tests/BehaviorSettingsFormAlterationsTest.php b/modules/rh_node/src/Tests/BehaviorSettingsFormAlterationsTest.php index 496e76d..c53224f 100644 --- a/modules/rh_node/src/Tests/BehaviorSettingsFormAlterationsTest.php +++ b/modules/rh_node/src/Tests/BehaviorSettingsFormAlterationsTest.php @@ -12,7 +12,7 @@ use Drupal\node\Entity\Node; use Drupal\rabbit_hole\Entity\BehaviorSettings; /** - * Test the functionality of the rabbit hole form additions to the node form + * Test the functionality of the rabbit hole form additions to the node form. * * @group rh_node */ @@ -45,7 +45,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { * of permissions */ $this->user = $this->drupalCreateUser(array( - 'bypass node access', 'administer content types' + 'bypass node access', 'administer content types', )); $this->behaviorSettingsManager = $this->container @@ -54,7 +54,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that the content type form of a newly created content type contains - * the expected fields + * the expected fields. */ public function testDefaultContentTypeForm() { $this->createTestContentType(); @@ -72,7 +72,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that saving changes to a content type form creates an appropriate - * behavior settings config key + * behavior settings config key. */ public function testContentTypeFormFirstSave() { $test_content_type_id = $this->createTestContentType(); @@ -83,7 +83,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $this->drupalPostForm(NULL, array( 'rh_override' => $override, - 'rh_action' => $action + 'rh_action' => $action, ), t('Save content type')); $saved_config = $this->behaviorSettingsManager->loadBehaviorSettingsAsConfig( @@ -94,7 +94,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that a content type form of a content type with a configured behavior - * properly loads configuration + * properly loads configuration. */ public function testContentTypeFormExistingBehavior() { $action = 'page_not_found'; @@ -102,10 +102,10 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $test_content_type_id = $this->createTestContentType(); $this->behaviorSettingsManager->saveBehaviorSettings(array( - 'action' => $action, - 'allow_override' => $override, - 'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE, - ), 'node_type', $test_content_type_id + 'action' => $action, + 'allow_override' => $override, + 'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE, + ), 'node_type', $test_content_type_id ); $this->loadContentTypeFormForTestType(); @@ -118,16 +118,16 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that saving changes to a content type form which already has configured - * rabbit hole behavior settings changes the existing key + * rabbit hole behavior settings changes the existing key. */ public function testContentTypeFormSave() { $test_content_type_id = $this->createTestContentType(); $this->behaviorSettingsManager->saveBehaviorSettings(array( - 'action' => 'access_denied', - 'allow_override' => BehaviorSettings::OVERRIDE_DISALLOW, - 'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE, - ), 'node_type', $test_content_type_id + 'action' => 'access_denied', + 'allow_override' => BehaviorSettings::OVERRIDE_DISALLOW, + 'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE, + ), 'node_type', $test_content_type_id ); $this->loadContentTypeFormForTestType(); @@ -137,7 +137,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $this->drupalPostForm(NULL, array( 'rh_override' => $override, - 'rh_action' => $action + 'rh_action' => $action, ), t('Save content type')); $saved_config = $this->behaviorSettingsManager->loadBehaviorSettingsAsConfig( @@ -149,7 +149,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that an existing node that previously didn't have settings will have - * settings saved when the node form is saved + * settings saved when the node form is saved. */ public function testExistingNodeNoConfigSave() { $this->createTestContentType(); @@ -159,7 +159,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $this->loadNodeFormForTestNode($node_id); $this->drupalPostForm(NULL, array( - 'rh_action' => $action + 'rh_action' => $action, ), t('Save')); $node = Node::Load($node_id); @@ -167,7 +167,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Test that an existing node entity is edited on saving the node form + * Test that an existing node entity is edited on saving the node form. */ public function testExistingNodeSave() { $this->createTestContentType(); @@ -177,7 +177,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $this->loadNodeFormForTestNode($node_id); $this->drupalPostForm(NULL, array( - 'rh_action' => $action + 'rh_action' => $action, ), t('Save')); $node = Node::Load($node_id); @@ -186,7 +186,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that when a node form is loaded it defaults to using the bundle - * configuration + * configuration. */ public function testDefaultNodeSettingsLoad() { $this->createTestContentType(); @@ -204,7 +204,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { /** * Test that a node form correctly loads previously saved rabbit hole behavior - * settings + * settings. */ public function testExistingNodeSettingsLoad() { $this->createTestContentType(); @@ -218,14 +218,15 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Create a content type for testing + * Create a content type for testing. + * * @return string The content type ID */ private function createTestContentType() { $node_type = NodeType::create( array( 'type' => self::TEST_CONTENT_TYPE_ID, - 'name' => self::TEST_CONTENT_TYPE_ID + 'name' => self::TEST_CONTENT_TYPE_ID, ) ); $node_type->save(); @@ -233,7 +234,8 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Create a node for testing + * Create a node for testing. + * * @return integer The node ID */ private function createTestNode($action = '') { @@ -252,7 +254,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Load the test content type form + * Load the test content type form. */ private function loadContentTypeFormForTestType() { $this->drupalLogin($this->user); @@ -262,7 +264,7 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Load the add new node form for the test content type + * Load the add new node form for the test content type. */ private function loadNewNodeFormForTestContentType() { $this->drupalLogin($this->user); @@ -272,7 +274,8 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { } /** - * Load the node form for the test node with the given ID + * Load the node form for the test node with the given ID. + * * @param $test_node_id The ID of the test node */ private function loadNodeFormForTestNode($test_node_id) { @@ -280,4 +283,5 @@ class BehaviorSettingsFormAlterationsTest extends WebTestBase { $this->drupalGet('node/' . $test_node_id . '/edit'); $this->assertResponse(200); } + } diff --git a/modules/rh_node/src/Tests/InvocationTest.php b/modules/rh_node/src/Tests/InvocationTest.php index de5193c..fdd923d 100644 --- a/modules/rh_node/src/Tests/InvocationTest.php +++ b/modules/rh_node/src/Tests/InvocationTest.php @@ -9,7 +9,6 @@ namespace Drupal\rh_node\Tests; use Drupal\simpletest\WebTestBase; use Drupal\node\Entity\NodeType; use Drupal\node\Entity\Node; -use Drupal\rabbit_hole\Entity\BehaviorSettings; /** * Test that rabbit hole behaviors are invoked correctly for nodes. @@ -42,7 +41,7 @@ class InvocationTest extends WebTestBase { /** * Test that a fresh node with a fresh content type takes the default action - * (displays the page) + * (displays the page). */ public function testNodeDefaults() { $type = $this->createTestNodeType(); @@ -53,7 +52,7 @@ class InvocationTest extends WebTestBase { /** * Test that a node with action not set or set to bundle_default will default - * to the bundle action + * to the bundle action. */ public function testDefaultToBundle() { $type = $this->createTestNodeType('access_denied'); @@ -68,7 +67,7 @@ class InvocationTest extends WebTestBase { /** * Test that a node set to access_denied overrides the bundle and returns a - * 403 response + * 403 response. */ public function testAccessDenied() { $type = $this->createTestNodeType(); @@ -79,7 +78,7 @@ class InvocationTest extends WebTestBase { /** * Test that a node set to display_page overrides the bundle and returns a - * 200 response + * 200 response. */ public function testDisplayPage() { $type = $this->createTestNodeType('access_denied'); @@ -88,32 +87,37 @@ class InvocationTest extends WebTestBase { $this->assertResponse(200); } + /** + * + */ public function testUrlRedirects() { $type = $this->createTestNodeType('access_denied'); $this->testUrlRedirect(301, $type); $this->testUrlRedirect(302, $type); $this->testUrlRedirect(303, $type); - // $this->testUrlRedirect(304, $type); + // $this->testUrlRedirect(304, $type);. $this->testUrlRedirect(305, $type); $this->testUrlRedirect(307, $type); } /** - * Test URL redirects with tokens + * Test URL redirects with tokens. + * * @todo */ public function testTokenizedUrlRedirect() {} /** - * Test redirects that use PHP code + * Test redirects that use PHP code. + * * @todo */ public function testCodeRedirect() {} /** * Test that a node set to page_not_found overrides the bundle and returns a - * 404 response + * 404 response. */ public function testPageNotFound() { $type = $this->createTestNodeType(); @@ -122,6 +126,9 @@ class InvocationTest extends WebTestBase { $this->assertResponse(404); } + /** + * + */ private function createTestNodeType($action = NULL) { $node_type = NodeType::create( array( @@ -137,6 +144,9 @@ class InvocationTest extends WebTestBase { return $node_type; } + /** + * + */ private function createTestNodeOfType($node_type_id = self::TEST_CONTENT_TYPE_ID, $action = NULL) { $node = Node::create( array( @@ -153,7 +163,7 @@ class InvocationTest extends WebTestBase { } /** - * Test some simple URL redirects + * Test some simple URL redirects. */ private function testUrlRedirect($redirect_code, $type) { global $base_root; @@ -168,4 +178,5 @@ class InvocationTest extends WebTestBase { $this->drupalGet(self::NODE_BASE_PATH . $node->id()); $this->assertUrl($base_root . $destination_path); } + } diff --git a/modules/rh_user/src/Plugin/RabbitHoleEntityPlugin/User.php b/modules/rh_user/src/Plugin/RabbitHoleEntityPlugin/User.php index 9a7960f..d0826ae 100644 --- a/modules/rh_user/src/Plugin/RabbitHoleEntityPlugin/User.php +++ b/modules/rh_user/src/Plugin/RabbitHoleEntityPlugin/User.php @@ -42,4 +42,5 @@ class User extends RabbitHoleEntityPluginBase { public function getGlobalFormSubmitHandlerAttachLocations() { return array(array('actions', 'submit', '#submit')); } + } diff --git a/src/Annotation/RabbitHoleEntityPlugin.php b/src/Annotation/RabbitHoleEntityPlugin.php index 60c4a60..0e57ad5 100644 --- a/src/Annotation/RabbitHoleEntityPlugin.php +++ b/src/Annotation/RabbitHoleEntityPlugin.php @@ -36,9 +36,10 @@ class RabbitHoleEntityPlugin extends Plugin { public $label; /** - * The string id of the affected entity + * The string id of the affected entity. * * @var string */ public $entity_type; + } diff --git a/src/BehaviorInvoker.php b/src/BehaviorInvoker.php index bd0902b..2a3f523 100644 --- a/src/BehaviorInvoker.php +++ b/src/BehaviorInvoker.php @@ -45,7 +45,6 @@ class BehaviorInvoker implements BehaviorInvokerInterface { /** * Drupal\rabbit_hole\EntityExtender definition. - * */ protected $rhEntityExtender; @@ -65,7 +64,8 @@ class BehaviorInvoker implements BehaviorInvokerInterface { } /** - * Invoke a rabbit hole behavior based on an entity's configuration + * Invoke a rabbit hole behavior based on an entity's configuration. + * * @note This assumes the entity is configured for use with Rabbit Hole - if * you pass an entity to this method and it does not have a rabbit hole * plugin it will use the defaults! @@ -84,7 +84,6 @@ class BehaviorInvoker implements BehaviorInvokerInterface { $response_allowed = $resp_use == $response_required || $resp_use == RabbitHoleBehaviorPluginInterface::USES_RESPONSE_SOMETIMES; - // Most plugins never make use of the response and only run when it's not // provided (i.e. on a request event). if ((!$response_allowed && $current_response == NULL) @@ -97,7 +96,7 @@ class BehaviorInvoker implements BehaviorInvokerInterface { return $plugin->performAction($entity, $current_response); } - // All other cases return NULL, meaning the response is unchanged + // All other cases return NULL, meaning the response is unchanged. else { return NULL; } @@ -105,7 +104,8 @@ class BehaviorInvoker implements BehaviorInvokerInterface { /** * Load a list of entity IDs supported by rabbit hole based on available - * plugins + * plugins. + * * @return array * An array of string entity ids */ @@ -120,7 +120,8 @@ class BehaviorInvoker implements BehaviorInvokerInterface { /** * Return an entity's rabbit hole configuration or, failing that, the default * configuration for the bundle (which itself will call the base default - * configuration if necessary) + * configuration if necessary). + * * @return array An array of values from the entity's fields matching the * base properties added by rabbit hole */ @@ -128,11 +129,11 @@ class BehaviorInvoker implements BehaviorInvokerInterface { $field_keys = array_keys($this->rhEntityExtender->getGeneralExtraFields()); $values = array(); // We trigger the default bundle action under the following circumstances: - // Entity does not have rh_action field + // Entity does not have rh_action field. $trigger_default_bundle_action = !$entity->hasField('rh_action') - // Entity has rh_action field but it's null (hasn't been set) + // Entity has rh_action field but it's null (hasn't been set). || $entity->get('rh_action')->value == NULL - // Entity has been explicitly set to use the default bundle action + // Entity has been explicitly set to use the default bundle action. || $entity->get('rh_action')->value == 'bundle_default'; if ($trigger_default_bundle_action) { @@ -155,4 +156,5 @@ class BehaviorInvoker implements BehaviorInvokerInterface { } return $values; } + } diff --git a/src/BehaviorSettingsInterface.php b/src/BehaviorSettingsInterface.php index 61628d0..f4b7d46 100644 --- a/src/BehaviorSettingsInterface.php +++ b/src/BehaviorSettingsInterface.php @@ -14,51 +14,62 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; */ interface BehaviorSettingsInterface extends ConfigEntityInterface { // Add get/set methods for your configuration properties here. - /** - * Set the configured action - * @param string $action The action to save + * Set the configured action. + * + * @param string $action + * The action to save */ public function setAction($action); /** - * Get the configured action + * Get the configured action. + * * @return string The action id */ public function getAction(); /** - * Set whether overrides are allowed if this is for a bundle - * @param integer $allow_override 0 (N/A), 1 (Allow) or 2 (Disallow) + * Set whether overrides are allowed if this is for a bundle. + * + * @param int $allow_override + * 0 (N/A), 1 (Allow) or 2 (Disallow) */ public function setAllowOverride($allow_override); /** - * Get whether overrides are allowed if this is for a bundle + * Get whether overrides are allowed if this is for a bundle. + * * @return integer */ public function getAllowOverride(); /** - * Set the redirect code if action is redirect - * @param integer $redirect_code The redirect code (0 for N/A) + * Set the redirect code if action is redirect. + * + * @param int $redirect_code + * The redirect code (0 for N/A) */ public function setRedirectCode($redirect_code); /** - * Get the redirect code if action is redirect + * Get the redirect code if action is redirect. */ public function getRedirectCode(); /** - * Set the redirect path if action is redirect - * @param string $redirect_path The redirect path + * Set the redirect path if action is redirect. + * + * @param string $redirect_path + * The redirect path */ public function setRedirectPath($redirect_path); /** - * Get the redirect path if action is redirect + * Get the redirect path if action is redirect. + * * @return string The redirect path */ public function getRedirectPath(); + } diff --git a/src/BehaviorSettingsManager.php b/src/BehaviorSettingsManager.php index a59a081..759c4f6 100644 --- a/src/BehaviorSettingsManager.php +++ b/src/BehaviorSettingsManager.php @@ -9,7 +9,6 @@ namespace Drupal\rabbit_hole; use Drupal\Core\Config\ConfigFactory; use Drupal\rabbit_hole\Entity\BehaviorSettings; -use Drupal\rabbit_hole\Exception\InvalidBehaviorSettingsException; /** * Class BehaviorSettingsManager. @@ -88,13 +87,18 @@ class BehaviorSettingsManager implements BehaviorSettingsManagerInterface { /** - * Generate a full ID based on entity type label, bundle label and entity id - * @param string $entity_type_id The entity type (e.g. node) as a string - * @param string $entity_id The entity ID as a string + * Generate a full ID based on entity type label, bundle label and entity id. + * + * @param string $entity_type_id + * The entity type (e.g. node) as a string + * @param string $entity_id + * The entity ID as a string + * * @return string The full id appropriate for a BehaviorSettings config entity */ private function generateBehaviorSettingsFullId($entity_type_id, $entity_id = '') { return $entity_type_id . (isset($entity_id) ? '_' . $entity_id : ''); } + } diff --git a/src/BehaviorSettingsManagerInterface.php b/src/BehaviorSettingsManagerInterface.php index 16c6d3e..34e550e 100644 --- a/src/BehaviorSettingsManagerInterface.php +++ b/src/BehaviorSettingsManagerInterface.php @@ -15,29 +15,41 @@ namespace Drupal\rabbit_hole; interface BehaviorSettingsManagerInterface { /** - * Save behavior settings for an entity or bundle + * Save behavior settings for an entity or bundle. + * * @param array settings The settings for the BehaviorSettings entity - * @param string $entity_type_id The entity type (e.g. node) as a string - * @param string $entity_id The entity ID as a string + * @param string $entity_type_id + * The entity type (e.g. node) as a string + * @param string $entity_id + * The entity ID as a string */ public function saveBehaviorSettings($settings, $entity_type_id, $entity_id); /** * Load rabbit hole behaviour settings appropriate to the given config or - * default settings if not available - * @param string $entity_type_label The entity type (e.g. node) as a string - * @param string $entity_id The entity ID as a string + * default settings if not available. + * + * @param string $entity_type_label + * The entity type (e.g. node) as a string + * @param string $entity_id + * The entity ID as a string + * * @return \Drupal\Core\Config\ImmutableConfig The BehaviorSettings Config object */ public function loadBehaviorSettingsAsConfig($entity_type_label, $entity_id); /** * Load editable rabbit hole behaviour settings appropriate to the given config - * or NULL if not available - * @param string $entity_type_label The entity type (e.g. node) as a string - * @param string $entity_id The entity ID as a string + * or NULL if not available. + * + * @param string $entity_type_label + * The entity type (e.g. node) as a string + * @param string $entity_id + * The entity ID as a string + * * @return \Drupal\Core\Config\ImmutableConfig|null The BehaviorSettings Config object */ public function loadBehaviorSettingsAsEditableConfig($entity_type_label, $entity_id); + } diff --git a/src/Entity/BehaviorSettings.php b/src/Entity/BehaviorSettings.php index 12eb8b7..f3b3382 100644 --- a/src/Entity/BehaviorSettings.php +++ b/src/Entity/BehaviorSettings.php @@ -51,19 +51,19 @@ class BehaviorSettings extends ConfigEntityBase implements BehaviorSettingsInter protected $id; /** - * The configured action (e.g. display_page) + * The configured action (e.g. display_page). * * @var string */ protected $action; /** - * Whether inherited behaviors can be edited (if this is a bundle) + * Whether inherited behaviors can be edited (if this is a bundle). */ protected $allow_override; /** - * The path to use for redirects (if the action is redirect) + * The path to use for redirects (if the action is redirect). * * @todo It may be possible to make this reliant on a plugin instead (i.e. * the redirect plugin) - if so, we should probably do this @@ -71,7 +71,7 @@ class BehaviorSettings extends ConfigEntityBase implements BehaviorSettingsInter protected $redirect_path; /** - * The code to use for redirects (if the action is redirect) + * The code to use for redirects (if the action is redirect). * * @todo It may be possible to make this reliant on a plugin instead (i.e. * the redirect plugin) - if so, we should probably do this @@ -111,18 +111,19 @@ class BehaviorSettings extends ConfigEntityBase implements BehaviorSettingsInter /** * {@inheritdoc} + * * @todo Possibly this should instead rely on the redirect plugin? */ public function setRedirectCode($redirect_code) { if (!in_array($redirect_code, array( - self::REDIRECT_NOT_APPLICABLE, - self::REDIRECT_MOVED_PERMANENTLY, - self::REDIRECT_FOUND, - self::REDIRECT_SEE_OTHER, - self::REDIRECT_NOT_MODIFIED, - self::REDIRECT_USE_PROXY, - self::REDIRECT_TEMPORARY_REDIRECT - ) + self::REDIRECT_NOT_APPLICABLE, + self::REDIRECT_MOVED_PERMANENTLY, + self::REDIRECT_FOUND, + self::REDIRECT_SEE_OTHER, + self::REDIRECT_NOT_MODIFIED, + self::REDIRECT_USE_PROXY, + self::REDIRECT_TEMPORARY_REDIRECT, + ) )) { throw new InvalidBehaviorSettingException('redirect_code'); } @@ -157,4 +158,5 @@ class BehaviorSettings extends ConfigEntityBase implements BehaviorSettingsInter public function getRedirectPath() { return $this->redirect_path; } + } diff --git a/src/EntityExtender.php b/src/EntityExtender.php index 2961ada..c4c03b2 100644 --- a/src/EntityExtender.php +++ b/src/EntityExtender.php @@ -44,8 +44,10 @@ class EntityExtender implements EntityExtenderInterface { } /** - * Return fields that rabbit hole adds for use in entity_base_field_info hooks - * @param string $entity_type_id The string ID of the entity type + * Return fields that rabbit hole adds for use in entity_base_field_info hooks. + * + * @param string $entity_type_id + * The string ID of the entity type */ public function getRabbitHoleFields($entity_type_id) { $entity_types = $this->rhEntityPluginManager->loadSupportedEntityTypes(); @@ -70,4 +72,5 @@ class EntityExtender implements EntityExtenderInterface { } return $fields; } + } diff --git a/src/EntityExtenderInterface.php b/src/EntityExtenderInterface.php index f40e825..cf223d2 100644 --- a/src/EntityExtenderInterface.php +++ b/src/EntityExtenderInterface.php @@ -14,7 +14,8 @@ namespace Drupal\rabbit_hole; */ interface EntityExtenderInterface { /** - * Get the extra fields that should be applied to all rabbit hole entities + * Get the extra fields that should be applied to all rabbit hole entities. */ public function getGeneralExtraFields(); + } diff --git a/src/EventSubscriber/RabbitHoleSubscriber.php b/src/EventSubscriber/RabbitHoleSubscriber.php index 7398a8a..cc02138 100644 --- a/src/EventSubscriber/RabbitHoleSubscriber.php +++ b/src/EventSubscriber/RabbitHoleSubscriber.php @@ -63,21 +63,21 @@ class RabbitHoleSubscriber implements EventSubscriberInterface { } /** - * Process events generically invoking rabbit hole behaviors if necessary + * Process events generically invoking rabbit hole behaviors if necessary. */ private function processEvent(Event $event) { // Don't process events with HTTP exceptions - those have either been thrown - // by us or have nothing to do with rabbit hole + // by us or have nothing to do with rabbit hole. if ($event->getRequest()->get('exception') != NULL) { return; } // We won't go ahead if we have an entity form (i.e. we're adding/editing - // an entity) + // an entity). if ($event->getRequest()->get('_entity_form') == NULL) { // We check for all of our known entity keys that work with rabbit hole // and invoke rabbit hole behavior on the first one we find (which - // should also be the only one) + // should also be the only one). $entity_keys = $this->rabbitHoleBehaviorInvoker->getPossibleEntityTypeKeys(); foreach ($entity_keys as $ekey) { $entity = $event->getRequest()->get($ekey); @@ -92,4 +92,5 @@ class RabbitHoleSubscriber implements EventSubscriberInterface { } } } + } diff --git a/src/Exception/InvalidBehaviorSettingException.php b/src/Exception/InvalidBehaviorSettingException.php index a79aa42..9be3d60 100644 --- a/src/Exception/InvalidBehaviorSettingException.php +++ b/src/Exception/InvalidBehaviorSettingException.php @@ -1,16 +1,29 @@ setting = $setting; } + /** + * + */ public function getSetting() { return $this->setting(); } + } diff --git a/src/Exception/InvalidRedirectResponseException.php b/src/Exception/InvalidRedirectResponseException.php index 95e2e0d..985ed21 100644 --- a/src/Exception/InvalidRedirectResponseException.php +++ b/src/Exception/InvalidRedirectResponseException.php @@ -1,10 +1,19 @@ 'hidden', - '#value' => $entity_type->id(), + '#type' => 'hidden', + '#value' => $entity_type->id(), ); // Add override setting if we're editing a bundle. @@ -241,24 +235,18 @@ class FormManglerService { * @todo Add redirect settings */ // Wrap the redirect settings in a fieldset. - // Get the default value for the redirect path. - // Build the descriptive text. Add some help text for PHP, if the user has the // permission to use PHP for evaluation. - // Add the redirect path setting. - /** * @todo Add token support */ // Display a list of tokens if the Token module is enabled. - /** * @todo Add specific options for redirect - possibly via the plugin? */ // Add the redirect respons setting. - /** * @todo Handle possible PHP code in redirect */ @@ -276,7 +264,6 @@ class FormManglerService { // If the implementing module provides a submit function for the bundle form, // we'll add it as a submit function for the attached form. We'll also make // sure that this won't be added for entity forms. - /** * @todo This should probably be moved out into plugins based on entity type */ @@ -284,7 +271,7 @@ class FormManglerService { $submit_handler_locations = $entity_plugin ->getFormSubmitHandlerAttachLocations(); - foreach($submit_handler_locations as $location) { + foreach ($submit_handler_locations as $location) { $array_ref = &$attach; foreach ($location as $subkey) { $array_ref = &$array_ref[$subkey]; @@ -299,9 +286,10 @@ class FormManglerService { /** * Handle general aspects of rabbit hole form submission (not specific to node - * etc.) + * etc.). + * * @param array $form - * @param type &$form_state + * @param string or int or object... &$form_state */ public function handleFormSubmit($form, $form_state) { if ($form_state->getValue('rh_is_bundle')) { @@ -318,9 +306,9 @@ class FormManglerService { 'action' => $form_state->getValue('rh_action'), 'allow_override' => $allow_override, 'redirect_path' => $form_state->getValue('rh_redirect_path') - ?: '', + ?: '', 'redirect_code' => $form_state->getValue('rh_redirect_code') - ?: BehaviorSettings::REDIRECT_NOT_APPLICABLE, + ?: BehaviorSettings::REDIRECT_NOT_APPLICABLE, ), $form_state->getValue('rh_entity_type'), isset($entity) ? $entity->id() : $form_state->getValue('rh_entity_type') @@ -330,7 +318,8 @@ class FormManglerService { /** * Load an array of rabbit hole behavior options from plugins in the format - * option id => label + * option id => label. + * * @return array An array of behavior options */ protected function loadBehaviorOptions() { @@ -342,10 +331,14 @@ class FormManglerService { } /** - * Add additional fields to the form based on behaviors - * @param array &$form The form - * @param type $form_state The form state - * @param type $form_id The form ID + * Add additional fields to the form based on behaviors. + * + * @param array &$form + * The form + * @param string or int or object... $form_state + * The form state + * @param string or int or object... $form_id + * The form ID */ protected function populateExtraBehaviorSections(&$form, $form_state, $form_id, Entity $entity = NULL, $entity_is_bundle = FALSE, @@ -359,8 +352,12 @@ class FormManglerService { } } + /** + * + */ protected function isEntityBundle($entity) { return is_subclass_of($entity, 'Drupal\Core\Config\Entity\ConfigEntityBundleBase'); } + } diff --git a/src/Plugin/RabbitHoleBehaviorPlugin/DisplayPage.php b/src/Plugin/RabbitHoleBehaviorPlugin/DisplayPage.php index 170f8c5..9e8c8d8 100644 --- a/src/Plugin/RabbitHoleBehaviorPlugin/DisplayPage.php +++ b/src/Plugin/RabbitHoleBehaviorPlugin/DisplayPage.php @@ -19,5 +19,4 @@ use Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase; class DisplayPage extends RabbitHoleBehaviorPluginBase { // Empty class: just does RabbitHoleBehaviorBase's defaults, which is nothing. - } diff --git a/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php b/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php index 01c18a8..849c189 100644 --- a/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php +++ b/src/Plugin/RabbitHoleBehaviorPlugin/PageRedirect.php @@ -14,7 +14,6 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Config\ImmutableConfig; use Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginBase; use Drupal\rabbit_hole\Exception\InvalidRedirectResponseException; -use Drupal\rabbit_hole\Plugin\RabbitHoleBehaviorPluginInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; @@ -64,8 +63,7 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { * {@inheritdoc} */ public function performAction(Entity $entity, Response $current_response = NULL) { - // return new RedirectResponse($this->path, $this->code); - + // Return new RedirectResponse($this->path, $this->code);. $target = $entity->get('rh_redirect')->value; if (substr($target, 0, 4) == 'get('rh_redirect_response')->value) { + switch ($entity->get('rh_redirect_response')->value) { case self::REDIRECT_MOVED_PERMANENTLY: case self::REDIRECT_FOUND: case self::REDIRECT_SEE_OTHER: @@ -83,10 +81,10 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { $entity->get('rh_redirect_response')->value); } else { - // If a response already exists we don't need to do anything with it + // If a response already exists we don't need to do anything with it. return $current_response; } - // TODO: I don't think this is the correct way to handle a 304 response + // TODO: I don't think this is the correct way to handle a 304 response. case self::REDIRECT_NOT_MODIFIED: if ($current_response === NULL) { $not_modified_response = new Response(); @@ -95,11 +93,11 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { return $not_modified_response; } else { - // If a response already exists we don't need to do anything with it + // If a response already exists we don't need to do anything with it. return $current_response; } - // TODO: I have no idea if this is actually the correct way to handle a - // 305 response in Symfony/D8. Documentation on it seems a bit sparse. + // TODO: I have no idea if this is actually the correct way to handle a + // 305 response in Symfony/D8. Documentation on it seems a bit sparse. case self::REDIRECT_USE_PROXY: if ($current_response === NULL) { $use_proxy_response = new Response(); @@ -108,7 +106,7 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { return $use_proxy_response; } else { - // If a response already exists we don't need to do anything with it + // If a response already exists we don't need to do anything with it. return $current_response; } default: @@ -156,7 +154,6 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { ); // Get the default value for the redirect path. - // Build the descriptive text. Add some help text for PHP, if the user has the // permission to use PHP for evaluation. $description = array(); @@ -172,7 +169,6 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { '#rows' => substr_count($redirect_path, "\r\n") + 2, ); // Display a list of tokens if the Token module is enabled. - // Add the redirect response setting. $form['rabbit_hole']['redirect']['rh_redirect_response'] = array( '#type' => 'select', @@ -209,4 +205,5 @@ class PageRedirect extends RabbitHoleBehaviorPluginBase { ->setLabel($this->t('Rabbit Hole redirect response code')) ->setDescription($this->t('Specifies the HTTP response code that should be used when perform a redirect.')); } + } diff --git a/src/Plugin/RabbitHoleBehaviorPluginBase.php b/src/Plugin/RabbitHoleBehaviorPluginBase.php index 243ef19..b0adb44 100644 --- a/src/Plugin/RabbitHoleBehaviorPluginBase.php +++ b/src/Plugin/RabbitHoleBehaviorPluginBase.php @@ -34,14 +34,14 @@ abstract class RabbitHoleBehaviorPluginBase extends PluginBase implements Rabbit * {@inheritdoc} */ public function settingsFormHandleSubmit(&$form, &$form_state) { - // No extra action to handle submission by default + // No extra action to handle submission by default. } /** * {@inheritdoc} */ public function alterExtraFields(array &$fields) { - // Don't change the fields by default + // Don't change the fields by default. } /** @@ -50,4 +50,5 @@ abstract class RabbitHoleBehaviorPluginBase extends PluginBase implements Rabbit public function usesResponse() { return RabbitHoleBehaviorPluginInterface::USES_RESPONSE_NEVER; } + } diff --git a/src/Plugin/RabbitHoleBehaviorPluginInterface.php b/src/Plugin/RabbitHoleBehaviorPluginInterface.php index 13f51a2..c6cb5b3 100644 --- a/src/Plugin/RabbitHoleBehaviorPluginInterface.php +++ b/src/Plugin/RabbitHoleBehaviorPluginInterface.php @@ -22,11 +22,12 @@ interface RabbitHoleBehaviorPluginInterface extends PluginInspectionInterface { /** * Perform the rabbit hole action. + * * @param $entity - * The entity the action is being performed on + * The entity the action is being performed on * @param $current_response - * The response as it currently exists before being replaced by the response - * returned by the rabbit hole plugin + * The response as it currently exists before being replaced by the response + * returned by the rabbit hole plugin */ public function performAction(Entity $entity); @@ -40,29 +41,30 @@ interface RabbitHoleBehaviorPluginInterface extends PluginInspectionInterface { * @param string $form_id * The form ID. * @param Entity $entity - * The entity used by the form - * @param boolean $entity_is_bundle - * Whether the entity is a bundle + * The entity used by the form + * @param bool $entity_is_bundle + * Whether the entity is a bundle * @param BehaviorSettings - * The behavior settings for the bundle of the entity (or the entity itself, - * if it is a bundle) + * 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); /** - * Handle submission of the settings form for this plugin + * Handle submission of the settings form for this plugin. */ public function settingsFormHandleSubmit(&$form, &$form_state); /** * Add to or adjust the fields added by rabbit hole. + * * @param $fields The array of fields to be altered */ public function alterExtraFields(array &$fields); /** - * Get whether this plugin uses a response to perform its action + * Get whether this plugin uses a response to perform its action. * * Override this to return one of USES_RESPONSE_NEVER, USES_RESPONSE_SOMETIMES, * or USES_RESPONSE_ALWAYS to indicate whether performAction should be invoked @@ -72,4 +74,5 @@ interface RabbitHoleBehaviorPluginInterface extends PluginInspectionInterface { * USES_RESPONSE_NEVER. */ public function usesResponse(); + } diff --git a/src/Plugin/RabbitHoleEntityPluginBase.php b/src/Plugin/RabbitHoleEntityPluginBase.php index a633371..39b6a35 100644 --- a/src/Plugin/RabbitHoleEntityPluginBase.php +++ b/src/Plugin/RabbitHoleEntityPluginBase.php @@ -41,4 +41,5 @@ abstract class RabbitHoleEntityPluginBase extends PluginBase implements RabbitHo public function getGlobalFormSubmitHandlerAttachLocations() { return array(array('actions', 'submit', '#submit')); } + } diff --git a/src/Plugin/RabbitHoleEntityPluginInterface.php b/src/Plugin/RabbitHoleEntityPluginInterface.php index 10cb657..ac23d6f 100644 --- a/src/Plugin/RabbitHoleEntityPluginInterface.php +++ b/src/Plugin/RabbitHoleEntityPluginInterface.php @@ -20,7 +20,7 @@ interface RabbitHoleEntityPluginInterface extends PluginInspectionInterface { * array( * array('actions', 'submit', '#publish'), * array('actions', 'publish', '#submit'), - * ) + * ). */ public function getFormSubmitHandlerAttachLocations(); @@ -30,14 +30,16 @@ interface RabbitHoleEntityPluginInterface extends PluginInspectionInterface { * array( * array('actions', 'submit', '#publish'), * array('actions', 'publish', '#submit'), - * ) + * ). + * * @return array A multidimensional array */ public function getBundleFormSubmitHandlerAttachLocations(); /** * Return the form ID of the global config form for the entity targeted by - * this plugin + * this plugin. + * * @return string The form ID of the global config form */ public function getGlobalConfigFormId(); @@ -48,7 +50,8 @@ interface RabbitHoleEntityPluginInterface extends PluginInspectionInterface { * array( * array('actions', 'submit', '#publish'), * array('actions', 'publish', '#submit'), - * ) + * ). */ public function getGlobalFormSubmitHandlerAttachLocations(); + } diff --git a/src/Plugin/RabbitHoleEntityPluginManager.php b/src/Plugin/RabbitHoleEntityPluginManager.php index faeb82b..324683b 100644 --- a/src/Plugin/RabbitHoleEntityPluginManager.php +++ b/src/Plugin/RabbitHoleEntityPluginManager.php @@ -18,7 +18,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; class RabbitHoleEntityPluginManager extends DefaultPluginManager { /** - * Drupal\Core\Entity\EntityTypeManagerInterface + * Drupal\Core\Entity\EntityTypeManagerInterface. */ private $etm; @@ -45,9 +45,11 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { /** * Create an instance of the first plugin found supporting the entity type - * with string id $entity_type + * with string id $entity_type. + * * @param string $entity_type - * The string ID of the entity type + * The string ID of the entity type + * * @return Drupal\rabbit_hole\Plugin\RabbitHoleEntityPluginInterface * The plugin */ @@ -57,9 +59,11 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { } /** - * Load plugins implementing entity with id $entity_type + * Load plugins implementing entity with id $entity_type. + * * @param string $entity_type - * The string ID of the entity type + * The string ID of the entity type + * * @return array * An array of plugin definitions for the entity type with ID $entity_type */ @@ -70,7 +74,8 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { } /** - * Load the string IDs for the supported entity types + * Load the string IDs for the supported entity types. + * * @return array * An array of entity type ID strings */ @@ -81,7 +86,8 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { } /** - * Load the string IDs for the supported bundle entity types + * Load the string IDs for the supported bundle entity types. + * * @return array * An array of entity type ID strings */ @@ -94,7 +100,8 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { /** * Load the string IDs for the global configuration - * forms for entity types + * forms for entity types. + * * @return array * An array of entity types and form ID strings in the form * form_id => entity_type @@ -109,4 +116,5 @@ class RabbitHoleEntityPluginManager extends DefaultPluginManager { } return $result; } + } diff --git a/src/Tests/RabbitHoleBehaviorPluginTest.php b/src/Tests/RabbitHoleBehaviorPluginTest.php index d6cd28d..13c3ab3 100644 --- a/src/Tests/RabbitHoleBehaviorPluginTest.php +++ b/src/Tests/RabbitHoleBehaviorPluginTest.php @@ -7,7 +7,6 @@ namespace Drupal\rabbit_hole\Tests; use Drupal\system\Tests\Plugin\PluginTestBase; -use Drupal\node\Entity\Node; /** * Test the functionality of the RabbitHoleBehavior plugin. @@ -139,4 +138,5 @@ class RabbitHoleBehaviorPluginTest extends PluginTestBase { // TODO: Check that $plugin->performAction() does what it's supposed to, // whatever that is. } + } diff --git a/src/Tests/RabbitHoleBehaviorSettingsEntityMethodsTest.php b/src/Tests/RabbitHoleBehaviorSettingsEntityMethodsTest.php index b67097d..c1c7c06 100644 --- a/src/Tests/RabbitHoleBehaviorSettingsEntityMethodsTest.php +++ b/src/Tests/RabbitHoleBehaviorSettingsEntityMethodsTest.php @@ -7,13 +7,11 @@ namespace Drupal\rabbit_hole\Tests; use Drupal\simpletest\WebTestBase; -use Drupal\node\Entity\NodeType; -use Drupal\node\Entity\Node; use Drupal\rabbit_hole\Entity\BehaviorSettings; use Drupal\rabbit_hole\Exception\InvalidBehaviorSettingException; /** - * Test the functionality of the rabbit hole form additions to the node form + * Test the functionality of the rabbit hole form additions to the node form. * * @group rabbit_hole */ @@ -36,7 +34,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { } /** - * Test creating a BehaviorSettings entity and loading it as config + * Test creating a BehaviorSettings entity and loading it as config. */ public function testCreateEntity() { $action = 'page_not_found'; @@ -64,20 +62,22 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { } /** - * Test that creating an entity with an invalid redirect code fails + * Test that creating an entity with an invalid redirect code fails. + * * @note Currently config entity constructors don't use setters - see * https://www.drupal.org/node/2399999 */ /** * Test that creating an entity with redirect settings when the action - * type is not redirect fails + * type is not redirect fails. + * * @note Currently config entity constructors don't use setters - see * https://www.drupal.org/node/2399999 */ /** - * Test that setAction() works as expected + * Test that setAction() works as expected. */ public function testSetAction() { $entity = $this->createGenericTestEntity(); @@ -88,7 +88,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { /** * Test that setAllowOverride works as expected (including throwing an - * exception if an invalid value is passed) + * exception if an invalid value is passed). */ public function testSetAllowOverride() { $entity = $this->createGenericTestEntity(); @@ -103,7 +103,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { /** * Test that setRedirectCode works as expected (including throwing an - * exception for invalid codes and settings codes when action type is wrong) + * exception for invalid codes and settings codes when action type is wrong). */ public function testSetRedirectCode() { $entity = $this->createGenericTestEntity(); @@ -128,7 +128,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { /** * Test that setRedirectPath works as expected (including throwing an - * exception for invalid codes and settings codes when action type is wrong) + * exception for invalid codes and settings codes when action type is wrong). */ public function testSetRedirectPath() { $entity = $this->createGenericTestEntity(); @@ -144,7 +144,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { } /** - * Create a generic test BehaviorSettings entity + * Create a generic test BehaviorSettings entity. */ private function createGenericTestEntity() { return BehaviorSettings::create( @@ -152,7 +152,7 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { 'id' => 'test_behavior_settings', 'action' => 'access_denied', 'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE, - 'redirect_path' => NULL + 'redirect_path' => NULL, ) ); } @@ -160,19 +160,26 @@ class RabbitHoleBehaviorSettingsEntityMethodsTest extends WebTestBase { /** * Test that a BehaviorSettingException gets thrown when $entity executes * $method with $args. This uses call_user_func internally. - * @param BehaviorSettings $entity The BehaviorSettings entity - * @param string $method The method to call - * @param array $args The arguments to pass to the method - * @param string $parent The name of the method which calls this method + * + * @param BehaviorSettings $entity + * The BehaviorSettings entity + * @param string $method + * The method to call + * @param array $args + * The arguments to pass to the method + * @param string $parent + * The name of the method which calls this method */ private function testBehaviorSettingExceptionThrown(BehaviorSettings $entity, $method, array $args, $parent) { $exception_was_thrown = FALSE; try { call_user_func(array($entity, $method), $args); - } catch (InvalidBehaviorSettingException $ex) { + } + catch (InvalidBehaviorSettingException $ex) { $exception_was_thrown = TRUE; } $this->assert($exception_was_thrown, 'Exception thrown executing ' . $method . ', called from ' . $parent); } + } diff --git a/src/Tests/RabbitHoleBehaviorSettingsTest.php b/src/Tests/RabbitHoleBehaviorSettingsTest.php index be93b1e..cd4546a 100644 --- a/src/Tests/RabbitHoleBehaviorSettingsTest.php +++ b/src/Tests/RabbitHoleBehaviorSettingsTest.php @@ -7,7 +7,6 @@ namespace Drupal\rabbit_hole\Tests; use Drupal\simpletest\WebTestBase; -use Drupal\node\Entity\NodeType; use Drupal\node\Entity\Node; use Drupal\rabbit_hole\Entity\BehaviorSettings; @@ -54,7 +53,7 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { /** * Test that a saved BehaviorSettings entity can be found by the config system - * and contains the correct values + * and contains the correct values. */ public function testSettings() { $this->saveAndTestExpectedValues(self::DEFAULT_ACTION, @@ -62,7 +61,7 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } /** - * Test that the default bundle settings exist and have the expected values + * Test that the default bundle settings exist and have the expected values. */ public function testBundleSettingsDefault() { $settings = \Drupal::config('rabbit_hole.behavior_settings.default'); @@ -77,7 +76,7 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { /** * Test that a saved BehaviourSettings entity can be given an ID based on - * a generated bundle (a NodeType in this case) and be found based on that ID + * a generated bundle (a NodeType in this case) and be found based on that ID. */ public function testBundleSettings() { $this->createTestNodeType(); @@ -87,12 +86,13 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } /** - * Test loading behavior settings for a nonexistent bundle returns defaults + * Test loading behavior settings for a nonexistent bundle returns defaults. + * * @return type */ public function testLoadBundleSettingsWithDefault() { // We search for a bundle that doesn't exist (named from a UUID) expecting - // to receive the default value + // to receive the default value. $action = $this->behaviorSettingsManager->loadBehaviorSettingsAsConfig( self::DEFAULT_TEST_ENTITY, 'f4515736-cfa0-4e38-b3ed-1306f56bd2a1')->get('action'); @@ -101,7 +101,7 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } /** - * Test loading editable for nonexistent behavior settings returns NULL + * Test loading editable for nonexistent behavior settings returns NULL. */ public function testLoadNullEditable() { $editable = $this->behaviorSettingsManager @@ -111,12 +111,12 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } /** - * Helper function to test saving and confirming config + * Helper function to test saving and confirming config. */ private function saveAndTestExpectedValues($expected_action, $calling_method, $entity_type_label = '', $entity_id = NULL) { - // Delete key if it already exists + // Delete key if it already exists. $editable = $this->behaviorSettingsManager->loadBehaviorSettingsAsEditableConfig( $entity_type_label, $entity_id); if (isset($editable)) { @@ -124,35 +124,35 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } $this->behaviorSettingsManager->saveBehaviorSettings(array( - 'action' => $expected_action, - 'allow_override' => 0, - 'redirect_code' => 0, - 'redirect_path' => '', - ), $entity_type_label, $entity_id); + 'action' => $expected_action, + 'allow_override' => 0, + 'redirect_code' => 0, + 'redirect_path' => '', + ), $entity_type_label, $entity_id); $action = $this->behaviorSettingsManager->loadBehaviorSettingsAsConfig( $entity_type_label, $entity_id)->get('action'); $this->assertEqual($action, $expected_action, 'Unexpected action ' . ' (called from ' . $calling_method . ')'); - // Clean up the entity afterwards + // Clean up the entity afterwards. $this->behaviorSettingsManager->loadBehaviorSettingsAsEditableConfig( $entity_type_label, $entity_id)->delete(); } /** - * Helper function to generate the test node type + * Helper function to generate the test node type. */ private function generateTestNodeType() { return \entity_create('node_type', array( 'type' => 'test_behavior_settings_node_type', - 'name' => 'Test Behavior Settings Node Type' + 'name' => 'Test Behavior Settings Node Type', ) ); } /** - * Helper function to generate the test node + * Helper function to generate the test node. */ private function generateTestNode() { return Node::create( @@ -165,28 +165,28 @@ class RabbitHoleBehaviorSettingsTest extends WebTestBase { } /** - * Helper function to create the test node type in the database + * Helper function to create the test node type in the database. */ private function createTestNodeType() { $this->testNodeType->save(); } /** - * Helper function to delete the test node type from the database + * Helper function to delete the test node type from the database. */ private function deleteTestNodeType() { $this->testNodeType->delete(); } /** - * Helper function to create the test node in the database + * Helper function to create the test node in the database. */ private function createTestNode() { $this->testNode->save(); } /** - * Helper function to delete the test node from the database + * Helper function to delete the test node from the database. */ private function deleteTestNode() { $this->testNode->delete();