Files
2025-08-02 16:30:27 +02:00

44 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\ComponentsBundle\View;
use KupShop\KupShopBundle\Util\System\BundleFinder;
use KupShop\KupShopBundle\Views\View;
use Symfony\Contracts\Service\Attribute\Required;
class ModalView extends View implements ComponentsViewInterface
{
use ComponentsViewTrait;
#[Required]
public BundleFinder $bundleFinder;
protected string $entrypoint = 'lazy';
public function getTemplates(): iterable
{
// List all template modals in bundles
foreach ($this->bundleFinder->getExistingBundlesPath('Resources/views/components/modal_lazy') as $bundle => $path) {
$prefix = str_replace('Bundle', '', $bundle);
foreach (glob("{$path}/*.html.twig") as $modal) {
$filename = pathinfo($modal)['basename'];
yield "@{$prefix}/components/modal_lazy/{$filename}";
}
}
// List all shop templates in modals
if (is_dir(__DIR__.'/../../../../../shop/twig/modal_lazy')) {
foreach (new \FilesystemIterator(__DIR__.'/../../../../../shop/twig/modal_lazy') as $file) {
yield 'modal_lazy/'.$file->getFilename();
}
}
// List all templates in modals
foreach (new \FilesystemIterator(__DIR__.'/../../../../web/common/twig/templates/modal_lazy') as $file) {
yield 'modal_lazy/'.$file->getFilename();
}
}
}