public function KeyAccessCheck::access in Translation Management Tool 8
Checks access for TMGMT job item.
Checks access for TMGMT job item by comparing the hashed key from job item data and key from the request.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The incoming request.
\Drupal\tmgmt\JobItemInterface $tmgmt_job_item: Job item.
Return value
AccessResult Returns TRUE if right key is in the request.
File
- sources/
content/ src/ Access/ KeyAccessCheck.php, line 31
Class
- KeyAccessCheck
- Checks access for TMGMT job item.
Namespace
Drupal\tmgmt_content\AccessCode
public function access(Request $request, JobItemInterface $tmgmt_job_item) {
$key_from_request = $request->query
->get('key');
$result = AccessResult::forbidden();
if ($key_from_request) {
if ($key_from_request === $this
->getKey($tmgmt_job_item) && $tmgmt_job_item
->getJob()
->isActive() && !($tmgmt_job_item
->isAborted() || $tmgmt_job_item
->isAccepted())) {
$result = AccessResult::allowed();
}
}
return $result
->setCacheMaxAge(0);
}