summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-09-22 14:23:33 (GMT)
committerAlex Pott2016-09-22 14:23:33 (GMT)
commitaef08f50f3268fd036ed07b7b8b9b6a3351fe4b4 (patch)
treefb7b674a162d7cced24333c98ad222052eae6c5b
parent57d9909de534462cd2453b111e99085fad5f54aa (diff)
Issue #2802301 by tstoeckler: Use route providers for ModerationState(|Transition)
-rw-r--r--core/modules/content_moderation/content_moderation.links.action.yml4
-rw-r--r--core/modules/content_moderation/content_moderation.routing.yml66
-rw-r--r--core/modules/content_moderation/src/Entity/ModerationState.php7
-rw-r--r--core/modules/content_moderation/src/Entity/ModerationStateTransition.php6
-rw-r--r--core/modules/content_moderation/src/ModerationStateAccessControlHandler.php9
-rw-r--r--core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php4
-rw-r--r--core/modules/content_moderation/src/Tests/ModerationStateTransitionsTest.php4
7 files changed, 18 insertions, 82 deletions
diff --git a/core/modules/content_moderation/content_moderation.links.action.yml b/core/modules/content_moderation/content_moderation.links.action.yml
index 9de5061..cbb2d3f 100644
--- a/core/modules/content_moderation/content_moderation.links.action.yml
+++ b/core/modules/content_moderation/content_moderation.links.action.yml
@@ -1,11 +1,11 @@
entity.moderation_state.add_form:
route_name: 'entity.moderation_state.add_form'
- title: 'Add Moderation state'
+ title: 'Add moderation state'
appears_on:
- entity.moderation_state.collection
entity.moderation_state_transition.add_form:
route_name: 'entity.moderation_state_transition.add_form'
- title: 'Add Moderation state transition'
+ title: 'Add moderation state transition'
appears_on:
- entity.moderation_state_transition.collection
diff --git a/core/modules/content_moderation/content_moderation.routing.yml b/core/modules/content_moderation/content_moderation.routing.yml
index cc7a5ff..912eed8 100644
--- a/core/modules/content_moderation/content_moderation.routing.yml
+++ b/core/modules/content_moderation/content_moderation.routing.yml
@@ -5,69 +5,3 @@ content_moderation.overview:
_title: 'Content moderation'
requirements:
_permission: 'access administration pages'
-
-# ModerationState routing definition
-entity.moderation_state.collection:
- path: '/admin/config/workflow/moderation/states'
- defaults:
- _entity_list: 'moderation_state'
- _title: 'Moderation states'
- requirements:
- _permission: 'administer moderation states'
-
-entity.moderation_state.add_form:
- path: '/admin/config/workflow/moderation/states/add'
- defaults:
- _entity_form: 'moderation_state.add'
- _title: 'Add Moderation state'
- requirements:
- _permission: 'administer moderation states'
-
-entity.moderation_state.edit_form:
- path: '/admin/config/workflow/moderation/states/{moderation_state}'
- defaults:
- _entity_form: 'moderation_state.edit'
- _title: 'Edit Moderation state'
- requirements:
- _permission: 'administer moderation states'
-
-entity.moderation_state.delete_form:
- path: '/admin/config/workflow/moderation/states/{moderation_state}/delete'
- defaults:
- _entity_form: 'moderation_state.delete'
- _title: 'Delete Moderation state'
- requirements:
- _permission: 'administer moderation states'
-
-# ModerationStateTransition routing definition
-entity.moderation_state_transition.collection:
- path: '/admin/config/workflow/moderation/transitions'
- defaults:
- _entity_list: 'moderation_state_transition'
- _title: 'Moderation state transitions'
- requirements:
- _permission: 'administer moderation state transitions'
-
-entity.moderation_state_transition.add_form:
- path: '/admin/config/workflow/moderation/transitions/add'
- defaults:
- _entity_form: 'moderation_state_transition.add'
- _title: 'Add Moderation state transition'
- requirements:
- _permission: 'administer moderation state transitions'
-
-entity.moderation_state_transition.edit_form:
- path: '/admin/config/workflow/moderation/transitions/{moderation_state_transition}'
- defaults:
- _entity_form: 'moderation_state_transition.edit'
- _title: 'Edit Moderation state transition'
- requirements:
- _permission: 'administer moderation state transitions'
-
-entity.moderation_state_transition.delete_form:
- path: '/admin/config/workflow/moderation/transitions/{moderation_state_transition}/delete'
- defaults:
- _entity_form: 'moderation_state_transition.delete'
- _title: 'Delete Moderation state transition'
- requirements:
- _permission: 'administer moderation state transitions'
diff --git a/core/modules/content_moderation/src/Entity/ModerationState.php b/core/modules/content_moderation/src/Entity/ModerationState.php
index 0522e7d..379ff60 100644
--- a/core/modules/content_moderation/src/Entity/ModerationState.php
+++ b/core/modules/content_moderation/src/Entity/ModerationState.php
@@ -19,8 +19,12 @@ use Drupal\content_moderation\ModerationStateInterface;
* "edit" = "Drupal\content_moderation\Form\ModerationStateForm",
* "delete" = "Drupal\content_moderation\Form\ModerationStateDeleteForm"
* },
+ * "route_provider" = {
+ * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
+ * },
* },
* config_prefix = "state",
+ * admin_permission = "administer moderation states",
* entity_keys = {
* "id" = "id",
* "label" = "label",
@@ -28,7 +32,8 @@ use Drupal\content_moderation\ModerationStateInterface;
* "weight" = "weight",
* },
* links = {
- * "edit-form" = "/admin/config/workflow/moderation/states/{moderation_state}/edit",
+ * "add-form" = "/admin/config/workflow/moderation/states/add",
+ * "edit-form" = "/admin/config/workflow/moderation/states/{moderation_state}",
* "delete-form" = "/admin/config/workflow/moderation/states/{moderation_state}/delete",
* "collection" = "/admin/config/workflow/moderation/states"
* },
diff --git a/core/modules/content_moderation/src/Entity/ModerationStateTransition.php b/core/modules/content_moderation/src/Entity/ModerationStateTransition.php
index 99dbf93..95a115b 100644
--- a/core/modules/content_moderation/src/Entity/ModerationStateTransition.php
+++ b/core/modules/content_moderation/src/Entity/ModerationStateTransition.php
@@ -18,6 +18,9 @@ use Drupal\content_moderation\ModerationStateTransitionInterface;
* "edit" = "Drupal\content_moderation\Form\ModerationStateTransitionForm",
* "delete" = "Drupal\content_moderation\Form\ModerationStateTransitionDeleteForm"
* },
+ * "route_provider" = {
+ * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
+ * },
* },
* config_prefix = "state_transition",
* admin_permission = "administer moderation state transitions",
@@ -28,7 +31,8 @@ use Drupal\content_moderation\ModerationStateTransitionInterface;
* "weight" = "weight"
* },
* links = {
- * "edit-form" = "/admin/config/workflow/moderation/transitions/{moderation_state_transition}/edit",
+ * "add-form" = "/admin/config/workflow/moderation/transitions/add",
+ * "edit-form" = "/admin/config/workflow/moderation/transitions/{moderation_state_transition}",
* "delete-form" = "/admin/config/workflow/moderation/transitions/{moderation_state_transition}/delete",
* "collection" = "/admin/config/workflow/moderation/transitions"
* }
diff --git a/core/modules/content_moderation/src/ModerationStateAccessControlHandler.php b/core/modules/content_moderation/src/ModerationStateAccessControlHandler.php
index cc2c977..b2c86d7 100644
--- a/core/modules/content_moderation/src/ModerationStateAccessControlHandler.php
+++ b/core/modules/content_moderation/src/ModerationStateAccessControlHandler.php
@@ -18,7 +18,7 @@ class ModerationStateAccessControlHandler extends EntityAccessControlHandler {
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
- $admin_access = AccessResult::allowedIfHasPermission($account, 'administer moderation states');
+ $admin_access = parent::checkAccess($entity, $operation, $account);
// Allow view with other permission.
if ($operation === 'view') {
@@ -28,11 +28,4 @@ class ModerationStateAccessControlHandler extends EntityAccessControlHandler {
return $admin_access;
}
- /**
- * {@inheritdoc}
- */
- protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
- return AccessResult::allowedIfHasPermission($account, 'administer moderation states');
- }
-
}
diff --git a/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php b/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php
index 1b394f9..3c5fd14 100644
--- a/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php
+++ b/core/modules/content_moderation/src/Tests/ModerationStateStatesTest.php
@@ -43,7 +43,7 @@ class ModerationStateStatesTest extends ModerationStateTestBase {
$this->assertLink('Moderation states');
$this->assertLink('Moderation state transitions');
$this->clickLink('Moderation states');
- $this->assertLink('Add Moderation state');
+ $this->assertLink('Add moderation state');
$this->assertText('Draft');
// Edit the draft.
$this->clickLink('Edit', 0);
@@ -59,7 +59,7 @@ class ModerationStateStatesTest extends ModerationStateTestBase {
'label' => 'Draft',
], t('Save'));
$this->assertText('Saved the Draft Moderation state.');
- $this->clickLink(t('Add Moderation state'));
+ $this->clickLink(t('Add moderation state'));
$this->drupalPostForm(NULL, [
'label' => 'Expired',
'id' => 'expired',
diff --git a/core/modules/content_moderation/src/Tests/ModerationStateTransitionsTest.php b/core/modules/content_moderation/src/Tests/ModerationStateTransitionsTest.php
index 0495e48..703561b 100644
--- a/core/modules/content_moderation/src/Tests/ModerationStateTransitionsTest.php
+++ b/core/modules/content_moderation/src/Tests/ModerationStateTransitionsTest.php
@@ -41,7 +41,7 @@ class ModerationStateTransitionsTest extends ModerationStateTestBase {
$this->drupalGet('admin/config/workflow/moderation');
$this->clickLink('Moderation state transitions');
- $this->assertLink('Add Moderation state transition');
+ $this->assertLink('Add moderation state transition');
$this->assertText('Create New Draft');
// Edit the Draft » Draft review.
@@ -71,7 +71,7 @@ class ModerationStateTransitionsTest extends ModerationStateTestBase {
// Add a new transition.
$this->drupalGet('admin/config/workflow/moderation/transitions');
- $this->clickLink(t('Add Moderation state transition'));
+ $this->clickLink(t('Add moderation state transition'));
$this->drupalPostForm(NULL, [
'label' => 'Published » Expired',
'id' => 'published_expired',