Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Created June 7, 2013 21:52
Show Gist options
  • Save vijaycs85/5732673 to your computer and use it in GitHub Desktop.
Save vijaycs85/5732673 to your computer and use it in GitHub Desktop.
diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml
index ccd5276..68e58b6 100644
--- a/core/modules/block/block.routing.yml
+++ b/core/modules/block/block.routing.yml
@@ -8,7 +8,7 @@ block_admin_block_delete:
block_admin_display:
pattern: '/admin/structure/block'
defaults:
- _controller: '\Drupal\block\Controller\BlockListController::listing'
+ _content: '\Drupal\block\Controller\BlockListController::listing'
entity_type: 'block'
requirements:
_permission: 'administer blocks'
diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php
index 5081ea5..5df109c 100644
--- a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php
+++ b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php
@@ -7,25 +7,67 @@
namespace Drupal\block\Controller;
-use Drupal\Core\Entity\Controller\EntityListController;
+
+use Drupal\Core\Config\Config;
+use Drupal\Core\Controller\ControllerInterface;
+use Drupal\Core\Entity\EntityManager;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a controller to list blocks.
*/
-class BlockListController extends EntityListController{
+class BlockListController implements ControllerInterface {
+
+ /**
+ * The entity manager
+ *
+ * @var \Drupal\Core\Entity\EntityManager
+ */
+ protected $entityManager;
+
+ /**
+ * The configuration object.
+ *
+ * @var \Drupal\Core\Config\Config
+ */
+ protected $config;
+
+
+ /**
+ * Creates an BlockListController object.
+ *
+ * @param \Drupal\Core\Entity\EntityManager $entity_manager
+ * The entity manager.
+ * @param \Drupal\Core\Config\Config $config
+ * Configuration object.
+ */
+ public function __construct(EntityManager $entity_manager, Config $config) {
+ $this->entityManager = $entity_manager;
+ $this->config = $config;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('plugin.manager.entity'),
+ $container->get('config.factory')
+ );
+ }
/**
* Shows the block administration page.
*
- * @param string $entity_type
* @param string|null $theme
+ * Theme key of block list.
*
* @return array|string
* A render array as expected by drupal_render().
*/
- public function listing($entity_type, $theme = NULL) {
- $default_theme = $theme ?: config('system.theme')->get('default');
- return $this->entityManager->getListController($entity_type)->render($default_theme);
+ public function listing($theme = NULL) {
+ $default_theme = $theme ?: $this->config->get('system.theme')->get('default');
+ return $this->entityManager->getListController('block')->render($default_theme);
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
index 5990b2f..e2d0248 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
@@ -47,6 +47,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
+
$this->controller = $this->container->get('plugin.manager.entity')->getStorageController('block');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment