diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php index aa60b27..f83a92e 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php @@ -44,10 +44,10 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques try { $shortcut->save(); - drupal_set_message($this->t('Added a shortcut for %title.', array('%title' => $name))); + drupal_set_message($this->t('Added a shortcut for %title.', array('%title' => $shortcut->label()))); } catch (\Exception $e) { - drupal_set_message($this->t('Unable to add a shortcut for %path.', array('%path' => $link))); + drupal_set_message($this->t('Unable to add a shortcut for %path.', array('%path' => $shortcut->path->value))); } return $this->redirect(''); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php index 3742897..4dd0aea 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php @@ -7,20 +7,55 @@ namespace Drupal\shortcut; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityAccessController; +use Drupal\Core\Entity\EntityControllerInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the access controller for the test entity type. */ -class ShortcutAccessController extends EntityAccessController { +class ShortcutAccessController extends EntityAccessController implements EntityControllerInterface { + + /** + * The shortcut_set storage controller. + * + * @var \Drupal\shortcut\ShortcutSetStorageController + */ + protected $shortcutSetStorage; + + /** + * Constructs a ShortcutAccessController object. + * + * @param string $entity_type + * The entity type of the access controller instance. + * @param array $entity_info + * An array of entity info for the entity type. + * @param \Drupal\shortcut\ShortcutSetStorageController $shortcut_set_storage + * The shortcut_set storage controller. + */ + public function __construct($entity_type, array $entity_info, ShortcutSetStorageController $shortcut_set_storage) { + parent::__construct($entity_type, $entity_info); + $this->shortcutSetStorage = $shortcut_set_storage; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $entity_type, + $entity_info, + $container->get('entity.manager')->getStorageController('shortcut_set') + ); + } /** * {@inheritdoc} */ protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - if ($shortcut_set = shortcut_set_load($entity->bundle())) { + if ($shortcut_set = $this->shortcutSetStorage->load($entity->bundle())) { return shortcut_set_edit_access($shortcut_set, $account); } } @@ -29,7 +64,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A * {@inheritdoc} */ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) { - if ($shortcut_set = shortcut_set_load($entity_bundle)) { + if ($shortcut_set = $this->shortcutSetStorage->load($entity_bundle)) { return shortcut_set_edit_access($shortcut_set, $account); } }