Skip to content

Instantly share code, notes, and snippets.

@cmcintosh
Last active November 30, 2019 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmcintosh/a4af632e8747f4874ad02e3d022ef9ab to your computer and use it in GitHub Desktop.
Save cmcintosh/a4af632e8747f4874ad02e3d022ef9ab to your computer and use it in GitHub Desktop.
TempleOfDoomViewsAccess.php
<?php
/**
* @ingroup views_access_plugins
*
* @ViewsAccess(
* id = "temple_of_doom",
* title = @Translation("Temple of Doom"),
* help = @Translation("No bad guys will enter, only Dr Jones may set foot inside.")
* )
*/
class TempleOfDoomViewsAccess extends AccessPluginBase {
public function summaryTitle() {
return $this->t('This Access Handler has stood guard over the treasure inside the Temple of Doom.');
}
public function access(AccountInterface $account) {
return $this->templeAccess->isUserTheGatekeeper($account) || $this->templeAccess->isUserTheKeymaster($account);
}
public function alterRouteDefinition(Route $route) {
$route->setRequirement('_custom_access', 'temple_of_doom.access_handler::access');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment