false, 'with_valid_to' => false, 'with_picto' => false, 'with_delimiter' => false, 'has_no_address' => false, 'multiline' => true, 'extended_infos' => false, ]; private EngineInterface $templating; public function __construct(EngineInterface $templating) { $this->templating = $templating; } /** * @param Address addr * @param mixed $addr */ public function renderBox($addr, array $options): string { $options = array_merge(self::DEFAULT_OPTIONS, $options); return $this->templating ->render('@ChillMain/Entity/address.html.twig', [ 'address' => $addr, 'render' => $options['render'] ?? 'bloc', 'options' => $options, ]); } /** * @param Address addr * @param mixed $addr */ public function renderString($addr, array $options): string { $lines = []; if (!empty($addr->getStreet())) { $lines[0] = $addr->getStreet(); } if (!empty($addr->getStreetNumber())) { $lines[0] .= ', ' . $addr->getStreetNumber(); } if (!empty($addr->getPostcode())) { $lines[1] = strtr('{postcode} {label}', [ '{postcode}' => $addr->getPostcode()->getCode(), '{label}' => $addr->getPostcode()->getName(), ]); } return implode(' - ', $lines); } public function supports($entity, array $options): bool { return $entity instanceof Address; } }