commit c337122c489858cedbb6badd6df6e7647bfd868c
Author: Bart Feenstra <bart@mynameisbart.com>
Date:   Thu Feb 20 10:47:27 2014 +0100

    bar

diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityAccessController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityAccessController.php
new file mode 100644
index 0000000..c2d10fa
--- /dev/null
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityAccessController.php
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Config\Entity\ConfigEntityAccessController.
+ */
+
+namespace Drupal\Core\Config\Entity;
+
+use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Provides default access control for configuration entities.
+ */
+class ConfigEntityAccessController extends EntityAccessController {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
+    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
+    if (in_array($operation, array('enable', 'disable'))) {
+      $has_status = $this->entityType->hasKey('status');
+      $status_is_toggleable = $operation == 'disable' ? $entity->status() : !$entity->status();
+      // We need to check access to an additional operation, so self::access()
+      // must be called.
+      return $has_status && $status_is_toggleable && $this->access($entity, 'update', $langcode, $account);
+    }
+    return parent::checkAccess($entity, $operation, $langcode, $account);
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php
index 54afad2..ccd35df 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php
@@ -33,19 +33,17 @@ public function load() {
   public function getOperations(EntityInterface $entity) {
     $operations = parent::getOperations($entity);
 
-    if ($this->entityType->hasKey('status')) {
-      if (!$entity->status() && $entity->hasLinkTemplate('enable')) {
-        $operations['enable'] = array(
-          'title' => t('Enable'),
-          'weight' => -10,
-        ) + $entity->urlInfo('enable');
-      }
-      elseif ($entity->hasLinkTemplate('disable')) {
-        $operations['disable'] = array(
-          'title' => t('Disable'),
-          'weight' => 40,
-        ) + $entity->urlInfo('disable');
-      }
+    if ($entity->access('enable') && $entity->hasLinkTemplate('enable')) {
+      $operations['enable'] = array(
+        'title' => t('Enable'),
+        'weight' => -10,
+      ) + $entity->urlInfo('enable');
+    }
+    if ($entity->access('disable') && $entity->hasLinkTemplate('disable')) {
+      $operations['disable'] = array(
+        'title' => t('Disable'),
+        'weight' => 40,
+      ) + $entity->urlInfo('disable');
     }
 
     return $operations;
diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php
index 9469ffc..df48014 100644
--- a/core/modules/block/lib/Drupal/block/BlockAccessController.php
+++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\block;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityControllerInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
@@ -19,7 +19,7 @@
 /**
  * Provides a Block access controller.
  */
-class BlockAccessController extends EntityAccessController implements EntityControllerInterface {
+class BlockAccessController extends ConfigEntityAccessController implements EntityControllerInterface {
 
   /**
    * The node grant storage.
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php
index cec5421..4b6cc0c 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php
@@ -7,20 +7,24 @@
 
 namespace Drupal\config_test;
 
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Session\AccountInterface;
-use Drupal\Core\Entity\EntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\Language;
 
 /**
  * Defines the access controller for the config_test entity type.
  */
-class ConfigTestAccessController extends EntityAccessController {
+class ConfigTestAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
    */
   public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
+    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
+    if (in_array($operation, array('enable', 'disable'))) {
+      return parent::checkAccess($entity, $operation, $langcode, $account);
+    }
     return TRUE;
   }
 
diff --git a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php
index f798d79..cbd2484 100644
--- a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php
+++ b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\contact;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
@@ -16,7 +16,7 @@
  *
  * @see \Drupal\contact\Entity\Category.
  */
-class CategoryAccessController extends EntityAccessController {
+class CategoryAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/filter/filter.routing.yml b/core/modules/filter/filter.routing.yml
index 6dd8138..acf7551 100644
--- a/core/modules/filter/filter.routing.yml
+++ b/core/modules/filter/filter.routing.yml
@@ -45,4 +45,4 @@ filter.admin_disable:
     _title: 'Disable text format'
   requirements:
     _filter_disable_format_access: 'TRUE'
-    _permission: 'administer filters'
+    _entity_access: filter_format.disable
diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php
index 9d3207d..79e1e35 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php
@@ -7,14 +7,14 @@
 
 namespace Drupal\filter;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines the access controller for the filter format entity type.
  */
-class FilterFormatAccessController extends EntityAccessController {
+class FilterFormatAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/language/lib/Drupal/language/LanguageAccessController.php b/core/modules/language/lib/Drupal/language/LanguageAccessController.php
index 2cc17d0..ef017e3 100644
--- a/core/modules/language/lib/Drupal/language/LanguageAccessController.php
+++ b/core/modules/language/lib/Drupal/language/LanguageAccessController.php
@@ -7,12 +7,12 @@
 
 namespace Drupal\language;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Session\AccountInterface;
 
-class LanguageAccessController extends EntityAccessController {
+class LanguageAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php b/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php
index 23ec80f..d31e2bd 100644
--- a/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php
+++ b/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\node;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
@@ -16,7 +16,7 @@
  *
  * @see \Drupal\node\Entity\NodeType.
  */
-class NodeTypeAccessController extends EntityAccessController {
+class NodeTypeAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/search/lib/Drupal/search/SearchPageAccessController.php b/core/modules/search/lib/Drupal/search/SearchPageAccessController.php
index cd51278..f435aea 100644
--- a/core/modules/search/lib/Drupal/search/SearchPageAccessController.php
+++ b/core/modules/search/lib/Drupal/search/SearchPageAccessController.php
@@ -8,14 +8,14 @@
 namespace Drupal\search;
 
 use Drupal\Core\Access\AccessibleInterface;
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines the access controller for the search page entity type.
  */
-class SearchPageAccessController extends EntityAccessController {
+class SearchPageAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/search/search.routing.yml b/core/modules/search/search.routing.yml
index 8cdec79..909faf4 100644
--- a/core/modules/search/search.routing.yml
+++ b/core/modules/search/search.routing.yml
@@ -36,7 +36,7 @@ search.enable:
     _controller: '\Drupal\search\Controller\SearchController::performOperation'
     op: 'enable'
   requirements:
-    _entity_access: 'search_page.update'
+    _entity_access: 'search_page.enable'
 
 search.disable:
   path: '/admin/config/search/settings/manage/{search_page}/disable'
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php
index c60d52a..7d45ed9 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php
@@ -7,14 +7,14 @@
 
 namespace Drupal\shortcut;
 
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityAccessController;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines the access controller for the shortcut entity type.
  */
-class ShortcutSetAccessController extends EntityAccessController {
+class ShortcutSetAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/system/lib/Drupal/system/DateFormatAccessController.php b/core/modules/system/lib/Drupal/system/DateFormatAccessController.php
index a5483b6..09ab273 100644
--- a/core/modules/system/lib/Drupal/system/DateFormatAccessController.php
+++ b/core/modules/system/lib/Drupal/system/DateFormatAccessController.php
@@ -7,14 +7,14 @@
 
 namespace Drupal\system;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Provides an access controller for date formats.
  */
-class DateFormatAccessController extends EntityAccessController {
+class DateFormatAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/system/lib/Drupal/system/MenuAccessController.php b/core/modules/system/lib/Drupal/system/MenuAccessController.php
index fe84368..8f440de 100644
--- a/core/modules/system/lib/Drupal/system/MenuAccessController.php
+++ b/core/modules/system/lib/Drupal/system/MenuAccessController.php
@@ -7,14 +7,14 @@
 
 namespace Drupal\system;
 
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityAccessController;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines the access controller for the menu entity type.
  */
-class MenuAccessController extends EntityAccessController {
+class MenuAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/user/lib/Drupal/user/RoleAccessController.php b/core/modules/user/lib/Drupal/user/RoleAccessController.php
index 0ab9ad8..c82d440 100644
--- a/core/modules/user/lib/Drupal/user/RoleAccessController.php
+++ b/core/modules/user/lib/Drupal/user/RoleAccessController.php
@@ -7,14 +7,14 @@
 
 namespace Drupal\user;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Session\AccountInterface;
 
 /**
  * Defines the access controller for the user_role entity type.
  */
-class RoleAccessController extends EntityAccessController {
+class RoleAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views/lib/Drupal/views/ViewAccessController.php b/core/modules/views/lib/Drupal/views/ViewAccessController.php
index e761af2..5f92b2c 100644
--- a/core/modules/views/lib/Drupal/views/ViewAccessController.php
+++ b/core/modules/views/lib/Drupal/views/ViewAccessController.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\views;
 
-use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Config\Entity\ConfigEntityAccessController;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Session\AccountInterface;
@@ -15,7 +15,7 @@
 /**
  * Defines the access controller for the view entity type.
  */
-class ViewAccessController extends EntityAccessController {
+class ViewAccessController extends ConfigEntityAccessController {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/views_ui.routing.yml b/core/modules/views_ui/views_ui.routing.yml
index ee6ad6c..3fbf1d5 100644
--- a/core/modules/views_ui/views_ui.routing.yml
+++ b/core/modules/views_ui/views_ui.routing.yml
@@ -52,7 +52,7 @@ views_ui.enable:
     _controller: '\Drupal\views_ui\Controller\ViewsUIController::ajaxOperation'
     op: enable
   requirements:
-    _permission: 'administer views'
+    _entity_access: view.enable
     _csrf_token: 'TRUE'
 
 views_ui.disable:
@@ -61,7 +61,7 @@ views_ui.disable:
     _controller: '\Drupal\views_ui\Controller\ViewsUIController::ajaxOperation'
     op: disable
   requirements:
-    _permission: 'administer views'
+    _entity_access: view.disable
     _csrf_token: 'TRUE'
 
 views_ui.clone:
