/**
  * Checks access for the subtree controller.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  * @param string $langcode
  *   The langcode of the requested site, NULL if none given.
  *
  * @return string
  *   Returns AccessInterface::ALLOW when access was granted, otherwise
  *   AccessInterface::DENY.
  */
 public function checkSubTreeAccess(Request $request, $langcode)
 {
     $hash = $request->get('hash');
     return $this->currentUser()->hasPermission('access toolbar') && $hash == _toolbar_get_subtrees_hash($langcode) ? AccessInterface::ALLOW : AccessInterface::DENY;
 }
Example #2
0
 /**
  * Checks access for the subtree controller.
  *
  * @param string $hash
  *   The hash of the toolbar subtrees.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function checkSubTreeAccess($hash)
 {
     $expected_hash = _toolbar_get_subtrees_hash()[0];
     return AccessResult::allowedIf($this->currentUser()->hasPermission('access toolbar') && Crypt::hashEquals($expected_hash, $hash))->cachePerPermissions();
 }
Example #3
0
 /**
  * Checks access for the subtree controller.
  *
  * @param string $hash
  *   The hash of the toolbar subtrees.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function checkSubTreeAccess($hash)
 {
     return AccessResult::allowedIf($this->currentUser()->hasPermission('access toolbar') && $hash == _toolbar_get_subtrees_hash()[0])->cachePerPermissions();
 }