diff --git a/core/lib/Drupal/Core/Controller/ControllerBase.php b/core/lib/Drupal/Core/Controller/ControllerBase.php index 2bfc4f2..3947f03 100644 --- a/core/lib/Drupal/Core/Controller/ControllerBase.php +++ b/core/lib/Drupal/Core/Controller/ControllerBase.php @@ -28,16 +28,6 @@ protected function entityManager() { } /** - * Returns the current primary database. - * - * @return \Drupal\Core\Database\Connection - * The current active database's master connection. - */ - protected function database() { - return $this->container->get('database'); - } - - /** * Returns the requested cache bin. * * @param string $bin @@ -156,49 +146,6 @@ protected function httpClient() { } /** - * Returns the entity query object for this entity type. - * - * @param string $entity_type - * The entity type, e.g. node, for which the query object should be - * returned. - * @param string $conjunction - * AND if all conditions in the query need to apply, OR if any of them is - * enough. Optional, defaults to AND. - * - * @return \Drupal\Core\Entity\Query\QueryInterface - * The query object that can query the given entity type. - */ - protected function entityQuery($entity_type, $conjunction = 'AND') { - return $this->container->get('entity.query')->get($entity_type, $conjunction); - } - - /** - * Returns the entity query aggregate object for this entity type. - * - * @param string $entity_type - * The entity type, e.g. node, for which the query object should be - * returned. - * @param string $conjunction - * AND if all conditions in the query need to apply, OR if any of them is - * enough. Optional, defaults to AND. - * - * @return \Drupal\Core\Entity\Query\QueryInterface - * The query object that can query the given entity type. - */ - protected function entityQueryAggregate($entity_type, $conjunction = 'AND') { - return $this->container->get('entity.query')->getAggregate($entity_type, $conjunction); - } - - /** - * Returns the flood instance. - * - * @return \Drupal\Core\Flood\FloodInterface - */ - protected function flood() { - return $this->container->get('flood'); - } - - /** * Returns the module handler. * * @return \Drupal\Core\Extension\ModuleHandlerInterface @@ -208,30 +155,6 @@ protected function moduleHandler() { } /** - * Returns the typed data manager service. - * - * Use the typed data manager service for creating typed data objects. - * - * @return \Drupal\Core\TypedData\TypedDataManager - * The typed data manager. - * - * @see \Drupal\Core\TypedData\TypedDataManager::create() - */ - protected function typedData() { - return $this->container->get('typed_data'); - } - - /** - * Returns the token service. - * - * @return \Drupal\Core\Utility\Token - * The token service. - */ - protected function token() { - return $this->container->get('token'); - } - - /** * Returns the url generator service. * * @return \Drupal\Core\Routing\PathBasedGeneratorInterface diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityListController.php b/core/lib/Drupal/Core/Entity/Controller/EntityListController.php index 5edbca1..7a07a38 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityListController.php @@ -7,40 +7,13 @@ namespace Drupal\Core\Entity\Controller; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a generic controller to list entities. */ -class EntityListController implements ControllerInterface { - - /** - * The entity manager - * - * @var \Drupal\Core\Entity\EntityManager - */ - protected $entityManager; - - /** - * Creates an EntityListController object. - * - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * The entity manager. - */ - public function __construct(EntityManager $entity_manager) { - $this->entityManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.entity') - ); - } +class EntityListController extends ControllerBase { /** * Provides the listing page for any entity type. @@ -52,7 +25,7 @@ public static function create(ContainerInterface $container) { * A render array as expected by drupal_render(). */ public function listing($entity_type) { - return $this->entityManager->getListController($entity_type)->render(); + return $this->entityManager()->getListController($entity_type)->render(); } } diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php index f7f4e38..0d065eb 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php @@ -7,33 +7,13 @@ namespace Drupal\block\Controller; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Controller\ControllerBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Controller for building the block instance add form. */ -class BlockAddController implements ControllerInterface { - - /** - * Constructs a Block object. - * - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * Entity manager service. - */ - public function __construct(EntityManager $entity_manager) { - $this->entityManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.entity') - ); - } +class BlockAddController extends ControllerBase { /** * Build the block instance add form. @@ -51,8 +31,9 @@ public function blockAddConfigureForm($plugin_id, $theme) { drupal_set_title(t('Configure block')); // Create a block entity. - $entity = $this->entityManager->getStorageController('block')->create(array('plugin' => $plugin_id, 'theme' => $theme)); + $entity = $this->entityManager()->getStorageController('block')->create(array('plugin' => $plugin_id, 'theme' => $theme)); - return $this->entityManager->getForm($entity); + return $this->entityManager()->getForm($entity); } + } diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php index 23b145c..832aaed 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php @@ -9,8 +9,6 @@ use Drupal\Core\Entity\Controller\EntityListController; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Config\ConfigFactory; -use Drupal\Core\Entity\EntityManager; /** * Defines a controller to list blocks. @@ -18,37 +16,6 @@ class BlockListController extends EntityListController { /** - * The configuration factory object. - * - * @var \Drupal\Core\Config\ConfigFactory - */ - protected $configFactory; - - - /** - * Creates an BlockListController object. - * - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * The entity manager. - * @param \Drupal\Core\Config\ConfigFactory $config_factory - * Configuration factory object. - */ - public function __construct(EntityManager $entity_manager, ConfigFactory $config_factory) { - $this->entityManager = $entity_manager; - $this->configFactory = $config_factory; - } - - /** - * {@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 @@ -60,8 +27,8 @@ public static function create(ContainerInterface $container) { * A render array as expected by drupal_render(). */ public function listing($entity_type, $theme = NULL) { - $default_theme = $theme ?: $this->configFactory->get('system.theme')->get('default'); - return $this->entityManager->getListController($entity_type)->render($default_theme); + $default_theme = $theme ?: $this->config('system.theme')->get('default'); + return $this->entityManager()->getListController($entity_type)->render($default_theme); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php index a67b53b..0e275f7 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php @@ -7,10 +7,7 @@ namespace Drupal\shortcut\Controller; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Entity\EntityManager; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Drupal\Core\Controller\ControllerBase; use Drupal\shortcut\ShortcutSetInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -20,55 +17,7 @@ /** * Builds the page for administering shortcut sets. */ -class ShortcutSetController implements ControllerInterface { - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * Stores the entity manager. - * - * @var \Drupal\Core\Entity\EntityManager - */ - protected $entityManager; - - /** - * The URL generator. - * - * @var \Drupal\Core\Routing\PathBasedGeneratorInterface - */ - protected $urlGenerator; - - /** - * Constructs a new \Drupal\shortcut\Controller\ShortCutController object. - * - * @param \Drupal\Core\Entity\EntityManager $entity_manager - * The entity manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator - * The URL generator. - */ - public function __construct(EntityManager $entity_manager, ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator) { - $this->entityManager = $entity_manager; - $this->moduleHandler = $module_handler; - $this->urlGenerator = $url_generator; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.entity'), - $container->get('module_handler'), - $container->get('url_generator') - ); - } +class ShortcutSetController extends ControllerBase { /** * Creates a new link in the provided shortcut set. @@ -93,7 +42,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques 'link_title' => $title, 'link_path' => $link, ); - $this->moduleHandler->loadInclude('shortcut', 'admin.inc'); + $this->moduleHandler()->loadInclude('shortcut', 'admin.inc'); shortcut_admin_add_link($link, $shortcut_set); if ($shortcut_set->save() == SAVED_UPDATED) { drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title']))); @@ -101,7 +50,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques else { drupal_set_message(t('Unable to add a shortcut for %title.', array('%title' => $link['link_title']))); } - return new RedirectResponse($this->urlGenerator->generateFromPath('', array('absolute' => TRUE))); + return new RedirectResponse($this->urlGenerator()->generateFromPath('', array('absolute' => TRUE))); } throw new AccessDeniedHttpException();