Commit 4f695034 authored by alexpott's avatar alexpott

Issue #2802301 by tstoeckler: Use route providers for ModerationState(|Transition)

(cherry picked from commit aef08f50)
parent 7047105a
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
......@@ -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'
......@@ -19,8 +19,12 @@
* "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 @@
* "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"
* },
......
......@@ -18,6 +18,9 @@
* "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 @@
* "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"
* }
......
......@@ -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 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
return $admin_access;
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'administer moderation states');
}
}
......@@ -43,7 +43,7 @@ public function testStateAdministration() {
$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 @@ public function testStateAdministration() {
'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',
......
......@@ -41,7 +41,7 @@ public function testTransitionAdministration() {
$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 @@ public function testTransitionAdministration() {
// 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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment