'; /** * @var TranslatableStringHelper */ private $translatableStringHelper; public function __construct(TranslatableStringHelper $translatableStringHelper) { $this->translatableStringHelper = $translatableStringHelper; } public function renderBox($entity, array $options): string { return $this->getDefaultOpeningBox('closing-motive') . $this->renderString($entity, $options) . $this->getDefaultClosingBox(); } /** * @param ClosingMotive $entity */ public function renderString($entity, array $options): string { return $this->renderStringRecursive( $entity, '', //$this->translatableStringHelper->localize($entity->getName()), $options ); } public function supports($entity, array $options): bool { return $entity instanceof ClosingMotive; } protected function renderStringRecursive(ClosingMotive $motive, $existing, array $options) { $newExisting = $this->translatableStringHelper->localize($motive->getName()); if ($motive->hasParent()) { if (!empty($existing)) { $newExisting = $newExisting . self::SEPARATOR . $existing; } return $this->renderStringRecursive( $motive->getParent(), $newExisting, $options ); } if (!empty($existing)) { return $newExisting . self::SEPARATOR . $existing; } return $newExisting; } }