Контроллер< /strong>
Код: Выделить всё
public function index(int $id, ManagerRegistry $doctrine): Response
{
$entityManager = $doctrine->getManager();
$establishment = $entityManager->getRepository(Establishment::class)->find($id);
$establishmentName = $establishment->getEstablishmentName();
$establishmentDirectory = $this->getParameter('media_directory').'/establishments_pages/'.$establishmentName;
$establishmentAssetDir = '/ressources/uploads/establishments_pages/'.$establishmentName;
$photos = [];
$buttons = [];
$count = 0;
$count1 = 1;
if ($establishmentDirectory) {
$results = scandir($establishmentDirectory);
foreach ($results as $value) {
if ($value !== '.'
&& $value !== '..'
&& $value !== 'Suite Deluxe'
&& $value !== 'Suite standard'
&& $value !== 'Suite VIP') {
if ($count === 0) {
$button = '';
$photo = '
[img]{{ asset([/img]
';
array_push($buttons, $button);
array_push($photos, $photo);
$count++;
$count1++;
} else {
$button = '';
$photo = '
[img]{{ asset([/img]
';
array_push($buttons, $button);
array_push($photos, $photo);
$count++;
$count1++;
}
}
}
} else {
echo 'Le dossier n\'existe pas.';
}
dump($photos);
return $this->render('establishment/establishment.html.twig', [
'id' => $id,
'establishment' => $establishment,
'establishmentName' => $establishmentName,
'establishmentDirectory' => $establishmentDirectory,
'buttons' => $buttons,
'photos' => $photos,
]);
}
array:3 [▼
0 => "
1 => "
2 => "
]
Но когда Twig интерпретирует этот код, он преобразует все косые черты на пробелы, ДАЖЕ ЕСЛИ я установил для функции unescape значение false!
Код TWIG:
Код: Выделить всё
{% autoescape false %}
{% for button in buttons %}
{{ button }}
{% endfor %}
{% for photo in photos %}
{{photo}}
{% endfor %}
{% endautoescape %}
Previous
Next
Я уже пытаюсь добавить встроенное "|raw" в переменную фотографии в TWIG, но это ничего не меняет!
Может ли кто-нибудь помочь мне сохранить мои пути?
Подробнее здесь: https://stackoverflow.com/questions/721 ... cape-false
Мобильная версия