-
-
Save sdboyer/5920080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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