我改写了树枝错误页面,并且有扩展程序可以获取一些布局设置,但是我无法在错误页面中访问此扩展程序
这是我的扩展名
/**
* Class ThemeExtension.
*/
class ThemeExtension extends AbstractExtension
{
use SettingManagerTrait;
/**
* @var TokenStorageInterface
*/
private $tokenStorage;
/**
* @var AuthorizationCheckerInterface
*/
private $authorizationChecker;
/**
* @var RequestStack
*/
private $stack;
/**
* @var array
*/
private $available_colors;
/**
* ThemeExtension constructor.
*
* @param TokenStorageInterface $tokenStorage
* @param AuthorizationCheckerInterface $authorizationChecker
* @param RequestStack $stack
* @param array $available_colors
*/
public function __construct(TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, RequestStack $stack, array $available_colors)
{
$this->tokenStorage = $tokenStorage;
$this->authorizationChecker = $authorizationChecker;
$this->stack = $stack;
$this->available_colors = $available_colors;
}
/**
* @return array
*/
public function getFunctions(): array
{
return [
new TwigFunction('theme_name', [$this, 'getThemeName']),
];
}
/**
* @return string
*
* @throws NonUniqueResultException
*/
public function getThemeName(): string
{
// stuff
}
}
如果有人知道,我想知道如何在错误页面中使用它。感谢您的帮助或想法。也许不可能