From 94c705b7aa8e3d8615f3e0b863711bd1af5897fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6rner?= Date: Tue, 31 Oct 2023 14:12:44 +0100 Subject: [PATCH] rename bundle class, make bundle installable under contao 5 --- src/Asset/PageEntrypoints.php | 8 ++----- src/ContaoManager/Plugin.php | 8 +++---- ...dle.php => HeimrichHannotEncoreBundle.php} | 9 ++++---- .../HeimrichHannotContaoEncoreBundleTest.php | 21 ------------------- tests/HeimrichHannotEncoreBundleTest.php | 21 +++++++++++++++++++ 5 files changed, 32 insertions(+), 35 deletions(-) rename src/{HeimrichHannotContaoEncoreBundle.php => HeimrichHannotEncoreBundle.php} (69%) delete mode 100644 tests/HeimrichHannotContaoEncoreBundleTest.php create mode 100644 tests/HeimrichHannotEncoreBundleTest.php diff --git a/src/Asset/PageEntrypoints.php b/src/Asset/PageEntrypoints.php index 20b988e..5e3af78 100644 --- a/src/Asset/PageEntrypoints.php +++ b/src/Asset/PageEntrypoints.php @@ -8,7 +8,6 @@ namespace HeimrichHannot\EncoreBundle\Asset; -use Contao\Database; use Contao\LayoutModel; use Contao\PageModel; use Contao\StringUtil; @@ -16,7 +15,6 @@ use HeimrichHannot\EncoreBundle\Collection\EntryCollection; use HeimrichHannot\EncoreBundle\Helper\ArrayHelper; use HeimrichHannot\UtilsBundle\Util\Utils; -use Symfony\Component\DependencyInjection\ContainerInterface; class PageEntrypoints { @@ -27,7 +25,6 @@ class PageEntrypoints protected $initialized = false; - private ContainerInterface $container; private FrontendAsset $frontendAsset; private EntryCollection $entryCollection; private Utils $utils; @@ -35,9 +32,8 @@ class PageEntrypoints /** * PageEntrypoints constructor. */ - public function __construct(ContainerInterface $container, FrontendAsset $frontendAsset, EntryCollection $entryCollection, Utils $utils) + public function __construct(FrontendAsset $frontendAsset, EntryCollection $entryCollection, Utils $utils) { - $this->container = $container; $this->frontendAsset = $frontendAsset; $this->entryCollection = $entryCollection; $this->utils = $utils; @@ -168,7 +164,7 @@ public function getActiveEntries(): array */ public function createInstance() { - return new self($this->container, $this->frontendAsset, $this->entryCollection, $this->utils); + return new self($this->frontendAsset, $this->entryCollection, $this->utils); } /** diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 77bdb8e..0e7b968 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -13,7 +13,7 @@ use Contao\ManagerPlugin\Bundle\Config\BundleConfig; use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; use Contao\ManagerPlugin\Config\ConfigPluginInterface; -use HeimrichHannot\EncoreBundle\HeimrichHannotContaoEncoreBundle; +use HeimrichHannot\EncoreBundle\HeimrichHannotEncoreBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\WebpackEncoreBundle\WebpackEncoreBundle; @@ -26,7 +26,7 @@ public function getBundles(ParserInterface $parser): array { return [ BundleConfig::create(WebpackEncoreBundle::class), - BundleConfig::create(HeimrichHannotContaoEncoreBundle::class)->setLoadAfter([ContaoCoreBundle::class]), + BundleConfig::create(HeimrichHannotEncoreBundle::class)->setLoadAfter([ContaoCoreBundle::class]), ]; } @@ -35,7 +35,7 @@ public function getBundles(ParserInterface $parser): array */ public function registerContainerConfiguration(LoaderInterface $loader, array $managerConfig) { - $loader->load('@HeimrichHannotContaoEncoreBundle/config/config.yml'); - $loader->load('@HeimrichHannotContaoEncoreBundle/config/services.yml'); + $loader->load('@HeimrichHannotEncoreBundle/config/config.yml'); + $loader->load('@HeimrichHannotEncoreBundle/config/services.yml'); } } diff --git a/src/HeimrichHannotContaoEncoreBundle.php b/src/HeimrichHannotEncoreBundle.php similarity index 69% rename from src/HeimrichHannotContaoEncoreBundle.php rename to src/HeimrichHannotEncoreBundle.php index be493d5..7a7a396 100644 --- a/src/HeimrichHannotContaoEncoreBundle.php +++ b/src/HeimrichHannotEncoreBundle.php @@ -11,26 +11,27 @@ use HeimrichHannot\EncoreBundle\DependencyInjection\EncoreConfigCompilerPass; use HeimrichHannot\EncoreBundle\DependencyInjection\EncoreExtension; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; -class HeimrichHannotContaoEncoreBundle extends Bundle +class HeimrichHannotEncoreBundle extends Bundle { /** * {@inheritdoc} */ - public function getContainerExtension() + public function getContainerExtension(): ?ExtensionInterface { return new EncoreExtension(); } - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); $container->addCompilerPass(new EncoreConfigCompilerPass()); } - public function getPath() + public function getPath(): string { return \dirname(__DIR__); } diff --git a/tests/HeimrichHannotContaoEncoreBundleTest.php b/tests/HeimrichHannotContaoEncoreBundleTest.php deleted file mode 100644 index cfdaf4d..0000000 --- a/tests/HeimrichHannotContaoEncoreBundleTest.php +++ /dev/null @@ -1,21 +0,0 @@ -assertInstanceOf(HeimrichHannotContaoEncoreBundle::class, $bundle); - } -} diff --git a/tests/HeimrichHannotEncoreBundleTest.php b/tests/HeimrichHannotEncoreBundleTest.php new file mode 100644 index 0000000..8da037f --- /dev/null +++ b/tests/HeimrichHannotEncoreBundleTest.php @@ -0,0 +1,21 @@ +assertInstanceOf(HeimrichHannotEncoreBundle::class, $bundle); + } +}