Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Forked from EclipseGc/gist:5919630
Last active December 19, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sdboyer/5920080 to your computer and use it in GitHub Desktop.
Save sdboyer/5920080 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")
* }
* )
*/
class MyPageContent implements ContentInterface {
protected $foo;
public function __construct(FooEntityInterface $foo) {
$this->foo = $foo;
}
/**
* Controller method/
*/
public function content() {
return entity_view('foo', $this->foo);
}
public function access(UserEntityInterface $user) {
return in_array('administrator', $user->roles) || $this->foo->uid == $user->uid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment