diff --git a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php index 45b9b94..e13ad62 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php @@ -22,7 +22,6 @@ class CategoryAccessController extends EntityAccessController { * {@inheritdoc} */ public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { - $this->prepareUser($account); if ($operation == 'delete' || $operation == 'update') { // Do not allow the 'personal' category to be deleted, as it's used for // the personal contact form. diff --git a/core/modules/contact/lib/Drupal/contact/Plugin/views/field/ContactLink.php b/core/modules/contact/lib/Drupal/contact/Plugin/views/field/ContactLink.php index 97f4dc1..dc9f055 100644 --- a/core/modules/contact/lib/Drupal/contact/Plugin/views/field/ContactLink.php +++ b/core/modules/contact/lib/Drupal/contact/Plugin/views/field/ContactLink.php @@ -8,13 +8,11 @@ namespace Drupal\contact\Plugin\views\field; use Drupal\Component\Annotation\PluginID; -use Drupal\Core\Access\StaticAccessCheckInterface; +use Drupal\Core\Access\AccessManager; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Routing\RouteProviderInterface; use Drupal\user\Plugin\views\field\Link; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Defines a field that links to the user contact page, if access is permitted. @@ -26,18 +24,11 @@ class ContactLink extends Link { /** - * The access manager for contact.personal_page route. + * The access manager. * - * @var \Drupal\Core\Access\StaticAccessCheckInterface + * @var \Drupal\Core\Access\AccessManager */ - protected $accessChecker; - - /** - * The router provider interface. - * - * @var \Drupal\Core\Routing\RouteProviderInterface - */ - protected $routeProvider; + protected $accessManager; /** * Constructs a Drupal\Component\Plugin\PluginBase object. @@ -48,15 +39,12 @@ class ContactLink extends Link { * The plugin_id for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Access\StaticAccessCheckInterface $access_checker - * The access manager for contact.personal_page route. - * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider - * The router provider interface. + * @param \Drupal\Core\Access\AccessManager $access_manager + * The access manager. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, StaticAccessCheckInterface $access_checker, RouteProviderInterface $route_provider) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, AccessManager $access_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->accessChecker = $access_checker; - $this->routeProvider = $route_provider; + $this->accessManager = $access_manager; } /** @@ -67,8 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('access_check.contact_personal'), - $container->get('router.route_provider') + $container->get('access_manager') ); } @@ -105,10 +92,7 @@ protected function renderLink(EntityInterface $entity, ResultRow $values) { $uid = $entity->id(); $path = "user/$uid/contact"; - $request = Request::create($path); - $request->attributes->set('user', $entity); - $route = $this->routeProvider->getRouteByName('contact.personal_page'); - if ($this->accessChecker->access($route, $request) !== StaticAccessCheckInterface::ALLOW) { + if ($this->accessManager->checkNamedRoute('contact.personal_page', array('user' => $uid))) { return; }