Skip to content

Instantly share code, notes, and snippets.

@EclipseGc
Last active December 19, 2015 07:38
Show Gist options
  • Save EclipseGc/5919630 to your computer and use it in GitHub Desktop.
Save EclipseGc/5919630 to your computer and use it in GitHub Desktop.
<?php
/**
* @Page(
* id = "my_page",
* title = @Translation("My page")
* routes = {
* @Route("/another/page/{foo}")
* @Route("/my/page/{foo}", "SomeOtherClass::access")
* }
* context = {
* "foo" = {
* "type" = "entity:foo"
* }
* }
* )
*/
class MyPageContent implements ContentInterface {
/**
* Controller method/
*/
public function content(FooEntityInterface $foo) {
return entity_view('foo', $foo);
}
public function access(UserEntityInterface $user, FooEntityInterface $foo) {
return in_array('administrator', $user->roles) || $foo->uid == $user->uid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment