configRepository = $configRepository; $this->translatableStringHelper = $translatableStringHelper; } public function displayLink($link, $family) { switch ($family) { case 'resource': return $this->translatableStringHelper->localize( $this->configRepository->getResourcesLabels()[$link] ); case 'charge': return $this->translatableStringHelper->localize( $this->configRepository->getChargesLabels()[$link] ); default: throw new UnexpectedValueException("This family of element: {$family} is not " . "supported. Supported families are 'resource', 'charge'"); } } public function getFilters() { return [ new TwigFilter('budget_element_type_display', [$this, 'displayLink'], ['is_safe' => ['html']]), ]; } }