vendor/sylius/theme-bundle/src/Asset/Installer/LegacyAssetsProvider.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\ThemeBundle\Asset\Installer;
  12. use Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProviderInterface;
  13. use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
  14. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  15. use Symfony\Component\HttpKernel\KernelInterface;
  16. /**
  17.  * @deprecated Deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.
  18.  */
  19. final class LegacyAssetsProvider implements AssetsProviderInterface
  20. {
  21.     private AssetsProviderInterface $assetsProvider;
  22.     private KernelInterface $kernel;
  23.     private ThemeHierarchyProviderInterface $themeHierarchyProvider;
  24.     public function __construct(AssetsProviderInterface $assetsProviderKernelInterface $kernelThemeHierarchyProviderInterface $themeHierarchyProvider)
  25.     {
  26.         @trigger_error(sprintf(
  27.             '"%s" is deprecated since Sylius/ThemeBundle 2.0 and will be removed in 3.0.',
  28.             self::class,
  29.         ), \E_USER_DEPRECATED);
  30.         $this->assetsProvider $assetsProvider;
  31.         $this->kernel $kernel;
  32.         $this->themeHierarchyProvider $themeHierarchyProvider;
  33.     }
  34.     public function provideDirectoriesForTheme(ThemeInterface $rootTheme): iterable
  35.     {
  36.         $themes array_reverse($this->themeHierarchyProvider->getThemeHierarchy($rootTheme));
  37.         foreach ($themes as $theme) {
  38.             foreach ($this->kernel->getBundles() as $bundle) {
  39.                 yield $theme->getPath() . '/' $bundle->getName() . '/public' => '/bundles/' $this->getPublicBundleName($bundle);
  40.             }
  41.         }
  42.         yield from $this->assetsProvider->provideDirectoriesForTheme($rootTheme);
  43.     }
  44.     public function provideDirectoriesForBundle(BundleInterface $bundle): iterable
  45.     {
  46.         yield from $this->assetsProvider->provideDirectoriesForBundle($bundle);
  47.     }
  48.     private function getPublicBundleName(BundleInterface $bundle): string
  49.     {
  50.         return (string) preg_replace('/bundle$/'''strtolower($bundle->getName()));
  51.     }
  52. }