Commit 0e011dfd authored by tim.plunkett's avatar tim.plunkett Committed by TravisCarden

Issue #2917760 by tim.plunkett, adriancid: ChecklistapiAccessCheck looks in...

Issue #2917760 by tim.plunkett, adriancid: ChecklistapiAccessCheck looks in the wrong place for 'checklist_id' and 'op'
parent f22d84fc
services:
access_check.checklistapi:
class: Drupal\checklistapi\Access\ChecklistapiAccessCheck
arguments: ['@request_stack']
tags:
- { name: access_check, applies_to: _checklistapi_access }
......@@ -4,42 +4,25 @@ namespace Drupal\checklistapi\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* An access check service for checklist routes.
*/
class ChecklistapiAccessCheck implements AccessInterface {
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Constructs a new ChecklistapiAccessCheck.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
}
class ChecklistapiAccessCheck implements AccessInterface {
/**
* Checks routing access for the checklist.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*
* @return \Drupal\Core\Access\AccessResult
* Returns an access result.
*/
public function access() {
$request = $this->requestStack->getCurrentRequest();
$op = $request->attributes->get('op');
$op = !empty($op) ? $op : 'any';
$id = $request->attributes->get('checklist_id');
public function access(RouteMatchInterface $route_match) {
$op = $route_match->getParameter('op') ?: 'any';
$id = $route_match->getParameter('checklist_id');
if (!$id) {
return AccessResult::neutral();
......@@ -47,4 +30,5 @@ class ChecklistapiAccessCheck implements AccessInterface {
return AccessResult::allowedIf(checklistapi_checklist_access($id, $op));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment