diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Access/ShortcutLinkUpdateAccessCheck.php b/core/modules/shortcut/lib/Drupal/shortcut/Access/ShortcutLinkUpdateAccessCheck.php index c1ce742..2aa0485 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Access/ShortcutLinkUpdateAccessCheck.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Access/ShortcutLinkUpdateAccessCheck.php @@ -2,12 +2,13 @@ /** * @file - * Contains Drupal\shortcut\Access\ShortcutLinkUpdateAccessCheck. + * Contains \Drupal\shortcut\Access\ShortcutLinkUpdateAccessCheck. */ namespace Drupal\shortcut\Access; use Drupal\Core\Access\StaticAccessCheckInterface; +use Drupal\Core\Entity\EntityManager; use Symfony\Component\Routing\Route; use Symfony\Component\HttpFoundation\Request; @@ -17,6 +18,23 @@ class ShortcutLinkUpdateAccessCheck implements StaticAccessCheckInterface { /** + * The shortcut set storage. + * + * @var \Drupal\shortcut\ShortcutSetStorageControllerInterface + */ + protected $shortcutSetStorage; + + /** + * Constructs a new ShortcutLinkUpdateAccessCheck. + * + * @param \Drupal\Core\Entity\EntityManager $entity_manager + * The entity manager. + */ + public function __construct(EntityManager $entity_manager) { + $this->shortcutSetStorage = $entity_manager->getStorageController('shortcut_set'); + } + + /** * {@inheritdoc} */ public function appliesTo() { @@ -29,7 +47,7 @@ public function appliesTo() { public function access(Route $route, Request $request) { $menu_link = $request->attributes->get('menu_link'); $set_name = str_replace('shortcut-', '', $menu_link['menu_name']); - if ($shortcut_set = shortcut_set_load($set_name)) { + if ($shortcut_set = $this->shortcutSetStorage->load($set_name)) { return $shortcut_set->access('update'); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php index 0f4c088..7ae7795 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php @@ -8,8 +8,6 @@ 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\shortcut\ShortcutSetInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -23,20 +21,6 @@ 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 @@ -46,16 +30,10 @@ class ShortcutSetController implements ControllerInterface { /** * 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; + public function __construct(PathBasedGeneratorInterface $url_generator) { $this->urlGenerator = $url_generator; } @@ -64,8 +42,6 @@ public function __construct(EntityManager $entity_manager, ModuleHandlerInterfac */ public static function create(ContainerInterface $container) { return new static( - $container->get('plugin.manager.entity'), - $container->get('module_handler'), $container->get('url_generator') ); } @@ -93,7 +69,6 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques 'link_title' => $title, 'link_path' => $link, ); - $this->moduleHandler->loadInclude('shortcut', 'admin.inc'); $shortcut_set->addLink($link); if ($shortcut_set->save() == SAVED_UPDATED) { drupal_set_message(t('Added a shortcut for %title.', array('%title' => $link['link_title']))); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkAddForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkAddForm.php index 89184f8..8035bc2 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkAddForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkAddForm.php @@ -7,9 +7,9 @@ namespace Drupal\shortcut\Form; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\menu_link\MenuLinkStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; /** * Builds the shortcut link add form. @@ -24,10 +24,20 @@ class ShortcutLinkAddForm extends ShortcutLinkFormBase { protected $menuLinkStorage; /** + * The shortcut set the link is being added to. + * * @var \Drupal\shortcut\ShortcutSetInterface */ protected $entity; + /** + * Constructs a new ShortcutLinkAddForm. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage + * The menu link storage. + */ public function __construct(ModuleHandlerInterface $module_handler, MenuLinkStorageControllerInterface $menu_link_storage) { parent::__construct($module_handler); $this->menuLinkStorage = $menu_link_storage; @@ -76,4 +86,5 @@ protected function getShortcutLink() { 'link_path' => '', )); } + } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkEditForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkEditForm.php index f506298..b6f2861 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkEditForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutLinkEditForm.php @@ -24,6 +24,8 @@ class ShortcutLinkEditForm extends ShortcutLinkFormBase { protected $aliasManager; /** + * Constructs a new ShortcutLinkEditForm. + * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php index d3ba64b..cde5d06 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\shortcut\Plugin\Core\Entity\ShortcutSetInterface. + * Contains \Drupal\shortcut\ShortcutSetInterface. */ namespace Drupal\shortcut; diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 8e59bc3..07d455c 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -5,9 +5,6 @@ * Allows users to manage customizable lists of shortcut links. */ -use Drupal\shortcut\Plugin\Core\Entity\Shortcut; -use Drupal\shortcut\ShortcutSetInterface; - /** * Implements hook_help(). */ diff --git a/core/modules/shortcut/shortcut.services.yml b/core/modules/shortcut/shortcut.services.yml index b83c1c4..ba52e71 100644 --- a/core/modules/shortcut/shortcut.services.yml +++ b/core/modules/shortcut/shortcut.services.yml @@ -1,5 +1,6 @@ services: access_check.shortcut.link: class: Drupal\shortcut\Access\ShortcutLinkUpdateAccessCheck + arguments: ['@plugin.manager.entity'] tags: - { name: access_check }