commit 5cacedb72516816e35a9f11ef503b7d5eb2df4ab
Author: Bart Feenstra <bart@mynameisbart.com>
Date:   Mon Apr 28 10:11:11 2014 +0200

    foo

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..4d2ae2b
--- /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_can_be_changed = $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_can_be_changed && $this->access($entity, 'update', $langcode, $account);
+    }
+    return parent::checkAccess($entity, $operation, $langcode, $account);
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
index 2bf8807..50b7857 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
@@ -34,19 +34,17 @@ public function getDefaultOperations(EntityInterface $entity) {
     /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
     $operations = parent::getDefaultOperations($entity);
 
-    if ($this->entityType->hasKey('status')) {
-      if (!$entity->status() && $entity->hasLinkTemplate('enable')) {
-        $operations['enable'] = array(
-          'title' => t('Enable'),
-          'weight' => -10,
-        ) + $entity->urlInfo('enable')->toArray();
-      }
-      elseif ($entity->hasLinkTemplate('disable')) {
-        $operations['disable'] = array(
-          'title' => t('Disable'),
-          'weight' => 40,
-        ) + $entity->urlInfo('disable')->toArray();
-      }
+    if ($entity->access('enable') && $entity->hasLinkTemplate('enable')) {
+      $operations['enable'] = array(
+        'title' => $this->t('Enable'),
+        'weight' => -10,
+      ) + $entity->urlInfo('enable')->toArray();
+    }
+    if ($entity->access('disable') && $entity->hasLinkTemplate('disable')) {
+      $operations['disable'] = array(
+        'title' => $this->t('Disable'),
+        'weight' => 40,
+      ) + $entity->urlInfo('disable')->toArray();
     }
 
     return $operations;
diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php
index 4f5182b..501977a 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/lib/Drupal/filter/FilterFormatAccess.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.php
index b6f6f58..f873399 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccess.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 FilterFormatAccess extends EntityAccessController {
+class FilterFormatAccess 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 38afb9f..c1f6f22 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/pages/manage/{search_page}/disable'
diff --git a/core/modules/shortcut/src/ShortcutSetAccessController.php b/core/modules/shortcut/src/ShortcutSetAccessController.php
index fd8d1b9..ad5aa1d 100644
--- a/core/modules/shortcut/src/ShortcutSetAccessController.php
+++ b/core/modules/shortcut/src/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}
