| @@ 58-80 (lines=23) @@ | ||
| 55 | * |
|
| 56 | * @return array<Twig_SimpleFilter> |
|
| 57 | */ |
|
| 58 | public function getFilters() |
|
| 59 | { |
|
| 60 | $filters = []; |
|
| 61 | $filterConfig = $this->getConfig('filter'); |
|
| 62 | ||
| 63 | foreach ($filterConfig as $className) { |
|
| 64 | /** @var FilterInterface $callable */ |
|
| 65 | $callable = $this->dependencyInjectionAdapter->get($className); |
|
| 66 | if ($callable instanceof FilterInterface) { |
|
| 67 | $filters[] = new Twig_SimpleFilter($callable::getName(), $callable); |
|
| 68 | } else { |
|
| 69 | throw new RuntimeException( |
|
| 70 | sprintf( |
|
| 71 | 'The class %s cannot be registered as Renderer/Filter!', |
|
| 72 | get_class($callable) |
|
| 73 | ), |
|
| 74 | 1000 |
|
| 75 | ); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| 79 | return $filters; |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Returns extension functions. |
|
| @@ 87-109 (lines=23) @@ | ||
| 84 | * |
|
| 85 | * @return array<Twig_SimpleFunction> |
|
| 86 | */ |
|
| 87 | public function getFunctions() : array |
|
| 88 | { |
|
| 89 | $functions = []; |
|
| 90 | $helperConfig = $this->getConfig('helper'); |
|
| 91 | ||
| 92 | foreach ($helperConfig as $className) { |
|
| 93 | /** @var HelperInterface $callable */ |
|
| 94 | $callable = $this->dependencyInjectionAdapter->get($className); |
|
| 95 | if ($callable instanceof HelperInterface) { |
|
| 96 | $functions[] = new Twig_SimpleFunction($callable::getName(), $callable); |
|
| 97 | } else { |
|
| 98 | throw new RuntimeException( |
|
| 99 | sprintf( |
|
| 100 | 'The class %s cannot be registered as Renderer/Helper!', |
|
| 101 | get_class($callable) |
|
| 102 | ), |
|
| 103 | 1001 |
|
| 104 | ); |
|
| 105 | } |
|
| 106 | } |
|
| 107 | ||
| 108 | return $functions; |
|
| 109 | } |
|
| 110 | ||
| 111 | /** |
|
| 112 | * Returns the renderer config by type. |
|