Last active
December 14, 2015 14:49
-
-
Save dspe/5103301 to your computer and use it in GitHub Desktop.
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 | |
namespace Pvr\PheelitBundle\Twig; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use eZ\Publish\Core\Repository\UserServiceInterface; | |
class PvrPheelitExtension extends \Twig_Extension | |
{ | |
private $container; | |
private $service_user; | |
public function __construct( ContainerInterface $container, UserServiceInterface $service_user ) | |
{ | |
$this->container = $container; | |
$this->service_user = $service_user; | |
} | |
public function getFilters() | |
{ | |
return array( | |
'user_name' => new \Twig_Filter_Method($this, 'userNameFilter'), | |
'displayImage' => new \Twig_Filter_Method($this, 'displayImage'), | |
); | |
} | |
// pas de filter... | |
public function userNameFilter($userId) | |
{ | |
//$userService = $this->container->get('ezpublish.api.repository')->getUserService(); | |
$user = $service_user->loadUser( $userId ); | |
return $user->content->contentInfo->name; | |
} |
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
services: | |
Pheelit.twig_extension: | |
class: %pheelit.twig_extension.class% | |
arguments: [@service_container, @ezpublish.api.service.user] | |
tags: | |
- { name: twig.extension } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment