Last active
October 12, 2015 07:21
-
-
Save bdunogier/952d297908094caf3648 to your computer and use it in GitHub Desktop.
Custom eZ Platform actions, before and after
This file contains hidden or 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 | |
class DemoController | |
{ | |
public function showBlogPostAction(Location $location, $viewType, $layout = false, array $params = array()) | |
{ | |
// We need the author, whatever the view type is. | |
$author = $this->userService->loadUser($location->getContentInfo()->ownerId); | |
// TODO once the keyword service is available, load the number of keyword for each keyword | |
// Delegate view rendering to the original ViewController | |
// (makes it possible to continue using defined template rules) | |
// We just add "author" to the list of variables exposed to the final template | |
return $this->get('ez_content')->viewLocation( | |
$location->id, | |
$viewType, | |
$layout, | |
array('author' => $author) + $params | |
); | |
} | |
} |
This file contains hidden or 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 | |
class DemoController | |
{ | |
public function showBlogPostAction(ContentView $view) | |
{ | |
$author = $this->userService()->loadUser($view->getContent()->contentInfo->ownerId); | |
$view->addParameters(['author' => $author]); | |
return $view; | |
} | |
} |
Did you forget the after file?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated usage of the
UserService
. It is pseudo code, let's say it is injected ;-)