Skip to content

Instantly share code, notes, and snippets.

@EclipseGc
Forked from sdboyer/gist:5920080
Last active December 19, 2015 07:39
Show Gist options
  • Save EclipseGc/5920201 to your computer and use it in GitHub Desktop.
Save EclipseGc/5920201 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")
* }
* contexts = {
* "foo" = {
* "type" = "string"
* }
* }
* )
*/
class MyPageContent implements ContentInterface {
protected $foo;
public function __construct($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