diff --git a/core/modules/content_moderation/content_moderation.install b/core/modules/content_moderation/content_moderation.install index 2b4fb5c..d8ea97b 100644 --- a/core/modules/content_moderation/content_moderation.install +++ b/core/modules/content_moderation/content_moderation.install @@ -5,6 +5,8 @@ * Contains install/update hooks for moderation_state. */ +use Drupal\Core\Entity\ContentEntityTypeInterface; + /** * Implements hook_install(). */ @@ -28,7 +30,7 @@ function content_moderation_install() { // here to filter out such broken entities. // @todo Remove when the underlying bug is fixed. // @see https://www.drupal.org/node/2674446 - $revisionable_entity_defintions = array_filter($revisionable_entity_defintions, function(\Drupal\Core\Entity\ContentEntityTypeInterface $type) use ($field_manager) { + $revisionable_entity_defintions = array_filter($revisionable_entity_defintions, function(ContentEntityTypeInterface $type) use ($field_manager) { return !empty($field_manager->getFieldStorageDefinitions($type->id())['moderation_state']); }); diff --git a/core/modules/content_moderation/src/Access/LatestRevisionCheck.php b/core/modules/content_moderation/src/Access/LatestRevisionCheck.php index 8632c4e..f0ae4b4 100644 --- a/core/modules/content_moderation/src/Access/LatestRevisionCheck.php +++ b/core/modules/content_moderation/src/Access/LatestRevisionCheck.php @@ -3,7 +3,6 @@ namespace Drupal\content_moderation\Access; use Drupal\Core\Access\AccessResult; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Routing\Access\AccessInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -33,7 +32,7 @@ public function __construct(ModerationInformationInterface $moderation_informati * This checker assumes the presence of an '_entity_access' requirement key * in the same form as used by EntityAccessCheck. * - * @see EntityAccessCheck. + * @see \Drupal\Core\Entity\EntityAccessCheck * * @param \Symfony\Component\Routing\Route $route * The route to check against. @@ -79,4 +78,5 @@ protected function loadEntity(Route $route, RouteMatchInterface $route_match) { } throw new \Exception(sprintf('%s is not a valid entity route. The LatestRevisionCheck access checker may only be used with a route that has a single entity parameter.', $route_match->getRouteName())); } + } diff --git a/core/modules/content_moderation/src/ContentPreprocess.php b/core/modules/content_moderation/src/ContentPreprocess.php index ec53d2a..df63a62 100644 --- a/core/modules/content_moderation/src/ContentPreprocess.php +++ b/core/modules/content_moderation/src/ContentPreprocess.php @@ -44,7 +44,7 @@ public function preprocessNode(array &$variables) { * A node. * * @return bool - * True if the current route is the latest version tab of the given node. + * True if the current route is the latest version tab of the given node. */ public function isLatestVersionPage(Node $node) { return $this->routeMatch->getRouteName() == 'entity.node.latest_version' diff --git a/core/modules/content_moderation/src/Entity/Handler/BlockContentModerationHandler.php b/core/modules/content_moderation/src/Entity/Handler/BlockContentModerationHandler.php index b698fac..152a8a3 100644 --- a/core/modules/content_moderation/src/Entity/Handler/BlockContentModerationHandler.php +++ b/core/modules/content_moderation/src/Entity/Handler/BlockContentModerationHandler.php @@ -1,8 +1,4 @@ moderationInfo->selectRevisionableEntityTypes($entity_types) as $type_name => $type) { @@ -161,7 +160,7 @@ protected function addModerationToEntityType(ConfigEntityTypeInterface $type) { * @return array * An array of operation definitions. * - * @see hook_entity_operation(). + * @see hook_entity_operation() */ public function entityOperation(EntityInterface $entity) { $operations = []; @@ -325,7 +324,7 @@ public function bundleFormAlter(array &$form, FormStateInterface $form_state, $f $this->entityTypeManager->getHandler($bundle->getEntityType()->getBundleOf(), 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id); } - else if ($this->moderationInfo->isModeratedEntityForm($form_state->getFormObject())) { + elseif ($this->moderationInfo->isModeratedEntityForm($form_state->getFormObject())) { /* @var ContentEntityInterface $entity */ $entity = $form_state->getFormObject()->getEntity(); @@ -357,4 +356,5 @@ public static function bundleFormRedirect(array &$form, FormStateInterface $form $form_state->setRedirect("entity.$entity_type_id.latest_version", [$entity_type_id => $entity->id()]); } } + } diff --git a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php index 26f3c1a..d072860 100644 --- a/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php +++ b/core/modules/content_moderation/src/Form/BundleModerationConfigurationForm.php @@ -2,9 +2,7 @@ namespace Drupal\content_moderation\Form; - use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; @@ -177,7 +175,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // If moderation is enabled, revisions MUST be enabled as well. // Otherwise we can't have forward revisions. - if($form_state->getValue('enable_moderation_state')) { + if ($form_state->getValue('enable_moderation_state')) { /* @var ConfigEntityTypeInterface $bundle */ $bundle = $form_state->getFormObject()->getEntity(); @@ -188,4 +186,5 @@ public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('Your settings have been saved.')); } + } diff --git a/core/modules/content_moderation/src/Form/EntityModerationForm.php b/core/modules/content_moderation/src/Form/EntityModerationForm.php index eb1ab9a..85e6805 100644 --- a/core/modules/content_moderation/src/Form/EntityModerationForm.php +++ b/core/modules/content_moderation/src/Form/EntityModerationForm.php @@ -2,12 +2,10 @@ namespace Drupal\content_moderation\Form; - use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\content_moderation\Entity\ModerationState; use Drupal\content_moderation\Entity\ModerationStateTransition; use Drupal\content_moderation\ModerationInformationInterface; use Drupal\content_moderation\StateTransitionValidation; @@ -138,4 +136,5 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->setRedirectUrl($entity->toUrl('canonical')); } } + } diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index 56e6227..2c2c8a9 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -209,5 +209,5 @@ public function isLiveRevision(ContentEntityInterface $entity) { && $entity->moderation_state->entity && $entity->moderation_state->entity->isPublishedState(); } -} +} diff --git a/core/modules/content_moderation/src/ModerationInformationInterface.php b/core/modules/content_moderation/src/ModerationInformationInterface.php index 290a5eb..f9f3a24 100644 --- a/core/modules/content_moderation/src/ModerationInformationInterface.php +++ b/core/modules/content_moderation/src/ModerationInformationInterface.php @@ -2,9 +2,7 @@ namespace Drupal\content_moderation; -use Drupal\Core\Config\Entity\ConfigEntityTypeInterface; use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormInterface; @@ -208,4 +206,5 @@ public function hasForwardRevision(ContentEntityInterface $entity); * TRUE if the specified entity is a live revision, FALSE otherwise. */ public function isLiveRevision(ContentEntityInterface $entity); + } diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php index 5277c89..c82e03d 100644 --- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php +++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutPublishNode.php @@ -59,4 +59,5 @@ public function access($object, AccountInterface $account = NULL, $return_as_obj return $return_as_object ? $result : $result->isAllowed(); } + } diff --git a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php index e14cb53..eed2cd4 100644 --- a/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php +++ b/core/modules/content_moderation/src/Plugin/Action/ModerationOptOutUnpublishNode.php @@ -59,4 +59,5 @@ public function access($object, AccountInterface $account = NULL, $return_as_obj return $return_as_object ? $result : $result->isAllowed(); } + } diff --git a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php index 2c4ebaa..f55bf1b 100644 --- a/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php +++ b/core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php @@ -121,4 +121,5 @@ protected function moderatableEntityTypeDefinitions() { && $entity_types[$bundle_of]->isRevisionable(); }); } + } diff --git a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php index 7b6404e..e1b70c5 100644 --- a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php +++ b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php @@ -13,7 +13,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\content_moderation\Entity\ModerationStateTransition; use Drupal\content_moderation\ModerationInformation; use Drupal\content_moderation\StateTransitionValidation; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/content_moderation/src/Plugin/views/filter/LatestRevision.php b/core/modules/content_moderation/src/Plugin/views/filter/LatestRevision.php index c73f4ec..995fcee 100644 --- a/core/modules/content_moderation/src/Plugin/views/filter/LatestRevision.php +++ b/core/modules/content_moderation/src/Plugin/views/filter/LatestRevision.php @@ -6,9 +6,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\views\Annotation\ViewsFilter; use Drupal\views\Plugin\views\filter\FilterPluginBase; -use Drupal\views\Plugin\views\query\Sql; use Drupal\views\Plugin\ViewsHandlerManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -127,4 +125,5 @@ public function query() { $query->ensureTable('content_revision_tracker', $this->relationship, $join); } + } diff --git a/core/modules/content_moderation/src/RevisionTrackerInterface.php b/core/modules/content_moderation/src/RevisionTrackerInterface.php index 5711743..e848b5b 100644 --- a/core/modules/content_moderation/src/RevisionTrackerInterface.php +++ b/core/modules/content_moderation/src/RevisionTrackerInterface.php @@ -24,4 +24,5 @@ * @return static */ public function setLatestRevision($entity_type, $entity_id, $langcode, $revision_id); + } diff --git a/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php b/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php index 9694a01..e78e5ad 100644 --- a/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php +++ b/core/modules/content_moderation/src/Routing/EntityModerationRouteProvider.php @@ -117,4 +117,5 @@ protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type) { $field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type->id()); return $field_storage_definitions[$entity_type->getKey('id')]->getType(); } + } diff --git a/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php b/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php index 528bafdd..c3c7e57 100644 --- a/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php +++ b/core/modules/content_moderation/src/Routing/EntityTypeModerationRouteProvider.php @@ -54,4 +54,5 @@ protected function getModerationFormRoute(EntityTypeInterface $entity_type) { return $route; } } + } diff --git a/core/modules/content_moderation/src/StateTransitionValidation.php b/core/modules/content_moderation/src/StateTransitionValidation.php index c9b1eab..cd511e9 100644 --- a/core/modules/content_moderation/src/StateTransitionValidation.php +++ b/core/modules/content_moderation/src/StateTransitionValidation.php @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Session\AccountInterface; -use Drupal\content_moderation\Entity\ModerationState; use Drupal\content_moderation\Entity\ModerationStateTransition; /** @@ -124,9 +123,6 @@ public function getValidTransitionTargets(ContentEntityInterface $entity, Accoun * @param \Drupal\Core\Session\AccountInterface $user * The account that wants to perform a transition. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * @param \Drupal\Core\Session\AccountInterface $user - * * @return ModerationStateTransition[] */ public function getValidTransitions(ContentEntityInterface $entity, AccountInterface $user) { @@ -134,7 +130,7 @@ public function getValidTransitions(ContentEntityInterface $entity, AccountInter /** @var ModerationState $current_state */ $current_state = $entity->moderation_state->entity; - $current_state_id = $current_state ? $current_state->id(): $bundle->getThirdPartySetting('content_moderation', 'default_moderation_state'); + $current_state_id = $current_state ? $current_state->id() : $bundle->getThirdPartySetting('content_moderation', 'default_moderation_state'); // Determine the states that are legal on this bundle. $legal_bundle_states = $bundle->getThirdPartySetting('content_moderation', 'allowed_moderation_states', []); @@ -279,4 +275,5 @@ protected function loadBundleEntity($bundle_entity_type_id, $bundle_id) { return $this->entityTypeManager->getStorage($bundle_entity_type_id)->load($bundle_id); } } + } diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php index 807d984..e1c3038 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTypeTest.php @@ -2,8 +2,6 @@ namespace Drupal\content_moderation\Tests; -use Drupal\Core\Session\AccountInterface; -use Drupal\user\Entity\Role; /** * Tests moderation state node type integration. @@ -68,4 +66,5 @@ public function testEnablingOnExistingContent() { $this->assertRaw('Save and Create New Draft'); $this->assertNoRaw('Save and publish'); } + } diff --git a/core/modules/content_moderation/src/Tests/NodeAccessTest.php b/core/modules/content_moderation/src/Tests/NodeAccessTest.php index 1454240..8148168 100644 --- a/core/modules/content_moderation/src/Tests/NodeAccessTest.php +++ b/core/modules/content_moderation/src/Tests/NodeAccessTest.php @@ -2,7 +2,6 @@ namespace Drupal\content_moderation\Tests; -use Drupal\node\NodeInterface; /** * Tests permission access control around nodes. @@ -109,4 +108,5 @@ public function testPageAccess() { $this->drupalGet($view_path); $this->assertResponse(200); } + } diff --git a/core/modules/content_moderation/tests/src/Functional/LatestRevisionViewsFilterTest.php b/core/modules/content_moderation/tests/src/Functional/LatestRevisionViewsFilterTest.php index e3a739a..308c2d3 100644 --- a/core/modules/content_moderation/tests/src/Functional/LatestRevisionViewsFilterTest.php +++ b/core/modules/content_moderation/tests/src/Functional/LatestRevisionViewsFilterTest.php @@ -12,7 +12,6 @@ * @group content_moderation * @runTestsInSeparateProcesses * @preserveGlobalState disabled - * */ class LatestRevisionViewsFilterTest extends BrowserTestBase { @@ -22,7 +21,7 @@ class LatestRevisionViewsFilterTest extends BrowserTestBase { public static $modules = ['content_moderation_test_views', 'content_moderation', 'node', 'views', 'options', 'user', 'system']; /** - * + * Tests view shows the correct node IDs. */ public function testViewShowsCorrectNids() { $node_type = $this->createNodeType('Test', 'test'); diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationSchemaTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationSchemaTest.php index ac2b028..07135b4 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationSchemaTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationSchemaTest.php @@ -31,11 +31,11 @@ public function testContentModerationDefaultConfig() { $typed_config = \Drupal::service('config.typed'); $moderation_states = ModerationState::loadMultiple(); foreach ($moderation_states as $moderation_state) { - $this->assertConfigSchema($typed_config, $moderation_state->getEntityType()->getConfigPrefix(). '.' . $moderation_state->id(), $moderation_state->toArray()); + $this->assertConfigSchema($typed_config, $moderation_state->getEntityType()->getConfigPrefix() . '.' . $moderation_state->id(), $moderation_state->toArray()); } $moderation_state_transitions = ModerationStateTransition::loadMultiple(); foreach ($moderation_state_transitions as $moderation_state_transition) { - $this->assertConfigSchema($typed_config, $moderation_state_transition->getEntityType()->getConfigPrefix(). '.' . $moderation_state_transition->id(), $moderation_state_transition->toArray()); + $this->assertConfigSchema($typed_config, $moderation_state_transition->getEntityType()->getConfigPrefix() . '.' . $moderation_state_transition->id(), $moderation_state_transition->toArray()); } } @@ -56,7 +56,7 @@ public function testContentModerationNodeTypeConfig() { $node_type->setThirdPartySetting('content_moderation', 'allowed_moderation_states', array_keys($moderation_states)); $node_type->setThirdPartySetting('content_moderation', 'default_moderation_state', ''); $node_type->save(); - $this->assertConfigSchema($typed_config, $node_type->getEntityType()->getConfigPrefix(). '.' . $node_type->id(), $node_type->toArray()); + $this->assertConfigSchema($typed_config, $node_type->getEntityType()->getConfigPrefix() . '.' . $node_type->id(), $node_type->toArray()); } /** @@ -77,7 +77,7 @@ public function testContentModerationBlockContentTypeConfig() { $block_content_type->setThirdPartySetting('content_moderation', 'allowed_moderation_states', array_keys($moderation_states)); $block_content_type->setThirdPartySetting('content_moderation', 'default_moderation_state', ''); $block_content_type->save(); - $this->assertConfigSchema($typed_config, $block_content_type->getEntityType()->getConfigPrefix(). '.' . $block_content_type->id(), $block_content_type->toArray()); + $this->assertConfigSchema($typed_config, $block_content_type->getEntityType()->getConfigPrefix() . '.' . $block_content_type->id(), $block_content_type->toArray()); } } diff --git a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php index 17c6e50..86b214f 100644 --- a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php @@ -6,7 +6,6 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; -use Drupal\node\NodeInterface; /** * @coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateValidator @@ -159,4 +158,5 @@ public function testLegacyMultilingualContent() { $node_fr->setTitle('Nouveau'); $node_fr->save(); } + } diff --git a/core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php b/core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php index bdc31e3..32f8fc3 100644 --- a/core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php +++ b/core/modules/content_moderation/tests/src/Unit/ContentPreprocessTest.php @@ -6,7 +6,6 @@ use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\node\Entity\Node; - /** * Class ContentPreprocessTest. * @@ -61,4 +60,5 @@ protected function setupNode($nid) { return $node->reveal(); } + } diff --git a/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php b/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php index c9eda19..11a65b7 100644 --- a/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php +++ b/core/modules/content_moderation/tests/src/Unit/LatestRevisionCheckTest.php @@ -3,15 +3,12 @@ namespace Drupal\Tests\content_moderation\Unit; use Drupal\block_content\Entity\BlockContent; -use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResultAllowed; use Drupal\Core\Access\AccessResultForbidden; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Routing\RouteMatch; use Drupal\node\Entity\Node; use Drupal\content_moderation\Access\LatestRevisionCheck; use Drupal\content_moderation\ModerationInformation; -use Drupal\content_moderation\ModerationInformationInterface; use Symfony\Component\Routing\Route; /** @@ -76,4 +73,5 @@ public function accessSituationProvider() { [BlockContent::class, 'block_content', FALSE, AccessResultForbidden::class], ]; } + }