Closed gharlan closed 5 months ago
Extensions are supported we just need:
twig:
globals:
service: @service
autocomplete for variables that are defined under twig: globals: do work, but using a service does not suggest Methods on this service.
twig:
globals:
service: '@AppBundle\Service\MyService'
using this in my template it does work.
{# @var service \AppBundle\Service\MyService #}
but If have to add this in every template, when I add it to my base template which is extended, it does not work within the child template.
Is there another way of doing this? Maybe with toolbox plugin like @Koc mentioned here: https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/468#issuecomment-230508799 https://github.com/Haehnchen/idea-php-toolbox
@Haehnchen
autocomplete for the global var is working now, but there is no autocomplete for methods on the service like
{{service.user.name}}
having this Service class for example
class MyService
{
/**
* @var AuthorizationCheckerInterface
*/
private $authorizationChecker;
/**
* @var TokenStorageInterface
*/
private $tokenStorage;
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TokenStorageInterface $tokenStorage)
{
$this->authorizationChecker = $authorizationChecker;
$this->tokenStorage = $tokenStorage;
}
/**
* @return bool
*/
public function isLoggedIn()
{
return $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED');
}
/**
* @return User|UserInterface
*/
public function getUser()
{
return $this->tokenStorage->getToken()->getUser();
}
}
Should be implemented by #31 but it does not work for me (and for @marapper, see https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/31#issuecomment-109659709)