diff --git a/composer.json b/composer.json index 18582643..62b58ada 100644 --- a/composer.json +++ b/composer.json @@ -17,24 +17,16 @@ "issues":"https://github.com/heimrichhannot/contao-banner_plus/issues" }, "require": { - "php": "~7.1", - "contao/core-bundle": "~4.4", - "bugbuster/contao-banner-bundle": "1.0.10.*", - "heimrichhannot/contao-mediaquery": "^1.1" + "php": "^7.2 || ^8.0", + "contao/core-bundle": "~4.9", + "bugbuster/contao-banner-bundle": ">=1.0.11 <1.4", + "heimrichhannot/contao-mediaquery": "^1.1", + "heimrichhannot/contao-utils-bundle": "^2.218" }, "autoload": { "psr-4": { "HeimrichHannot\\BannerPlusBundle\\": "src/" - }, - "classmap": [ - "src/Resources/contao/" - ], - "exclude-from-classmap": [ - "src/Resources/contao/config/", - "src/Resources/contao/dca/", - "src/Resources/contao/languages/", - "src/Resources/contao/templates/" - ] + } }, "extra": { "contao-manager-plugin": "HeimrichHannot\\BannerPlusBundle\\ContaoManager\\Plugin" diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index 1e9b54d5..4d0226ef 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -45,6 +45,5 @@ public function getBundles(ParserInterface $parser) public function registerContainerConfiguration(LoaderInterface $loader, array $managerConfig) { $loader->load('@ContaoBannerPlusBundle/Resources/config/services.yml'); - $loader->load('@ContaoBannerPlusBundle/Resources/config/listeners.yml'); } } \ No newline at end of file diff --git a/src/EventListener/CompileSlickNewsListListener.php b/src/EventListener/CompileSlickNewsListListener.php index 36a1ca35..310245de 100644 --- a/src/EventListener/CompileSlickNewsListListener.php +++ b/src/EventListener/CompileSlickNewsListListener.php @@ -27,7 +27,6 @@ class CompileSlickNewsListListener */ public function onCompileSlickNewsList(&$objTemplate, $frontendModule, $objModel) { - $slickBannerGenerator = new SlickBannerTemplate(); $slickBannerGenerator->generateSlickBanner($objTemplate, $frontendModule, $objModel); } diff --git a/src/EventListener/InitializeSystemListener.php b/src/EventListener/InitializeSystemListener.php index 8d4637c6..382a52c0 100644 --- a/src/EventListener/InitializeSystemListener.php +++ b/src/EventListener/InitializeSystemListener.php @@ -12,11 +12,20 @@ namespace HeimrichHannot\BannerPlusBundle\EventListener; -use Contao\System; -use HeimrichHannot\UtilsBundle\Container\ContainerUtil; +use Contao\CoreBundle\ServiceAnnotation\Hook; +use HeimrichHannot\UtilsBundle\Util\Utils; +/** + * @Hook("initializeSystem") + */ class InitializeSystemListener { + private Utils $utils; + + public function __construct(Utils $utils) + { + $this->utils = $utils; + } /** * @Hook("initializeSystem") @@ -42,9 +51,7 @@ public function onInitializeSystem() private function addBackendAssets() { - $containerUtil = System::getContainer()->get(ContainerUtil::class); - - if ($containerUtil->isBackend()) { + if ($this->utils->container()->isBackend()) { $GLOBALS['TL_JAVASCRIPT']['be_bannerplusbundle'] = 'bundles/contaobannerplus/assets/contao-banner-plus-bundle-be.js|static'; } } diff --git a/src/EventListener/LoadDataContainerListener.php b/src/EventListener/LoadDataContainerListener.php index 702d6ebc..8e025d39 100644 --- a/src/EventListener/LoadDataContainerListener.php +++ b/src/EventListener/LoadDataContainerListener.php @@ -12,16 +12,16 @@ namespace HeimrichHannot\BannerPlusBundle\EventListener; +use Contao\CoreBundle\ServiceAnnotation\Hook; use Contao\ModuleLoader; use HeimrichHannot\BannerPlusBundle\Type\HtmlType; +/** + * @Hook("loadDataContainer") + */ class LoadDataContainerListener { - - /** - * @Hook("loadDataContainer") - */ - public function onLoadDataContainer(string $table): void + public function __invoke(string $table): void { switch ($table) { case 'tl_module': @@ -33,7 +33,7 @@ public function onLoadDataContainer(string $table): void } } - public function updateModuleDataContainer() + public function updateModuleDataContainer(): void { $dc = &$GLOBALS['TL_DCA']['tl_module']; $active = ModuleLoader::getActive(); @@ -47,7 +47,7 @@ public function updateModuleDataContainer() } } - public function updateBannerDataContainer(string $table) + public function updateBannerDataContainer(string $table): void { $dca = &$GLOBALS['TL_DCA'][$table]; $options = HtmlType::BANNER_TYPES; diff --git a/src/EventListener/ReplaceInsertTagsListener.php b/src/EventListener/ReplaceInsertTagsListener.php index da4cc570..0e6ad8b5 100644 --- a/src/EventListener/ReplaceInsertTagsListener.php +++ b/src/EventListener/ReplaceInsertTagsListener.php @@ -16,9 +16,6 @@ class ReplaceInsertTagsListener { - /** - * @Hook("replaceInsertTags") - */ public function onReplaceInsertTags(string $insertTag) { $bannerGenerator = new BannerTemplate(); diff --git a/src/Resources/config/listeners.yml b/src/Resources/config/listeners.yml deleted file mode 100644 index 515d1b91..00000000 --- a/src/Resources/config/listeners.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - _defaults: - autowire: true - public: true - - HeimrichHannot\BannerPlusBundle\EventListener\InitializeSystemListener: ~ \ No newline at end of file diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 30f63776..d973b6bd 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -3,4 +3,8 @@ services: public: true autowire: true + HeimrichHannot\BannerPlusBundle\: + resource: '../../{EventListener}/*' + autoconfigure: true + HeimrichHannot\BannerPlusBundle\Type\HtmlType: ~ \ No newline at end of file diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index f2029e4d..8883cc32 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -9,9 +9,6 @@ */ -$GLOBALS['TL_HOOKS']['initializeSystem']['huh_banner_plus'] = [\HeimrichHannot\BannerPlusBundle\EventListener\InitializeSystemListener::class, 'onInitializeSystem']; -$GLOBALS['TL_HOOKS']['loadDataContainer']['huh_banner_plus'] = [\HeimrichHannot\BannerPlusBundle\EventListener\LoadDataContainerListener::class, 'onLoadDataContainer']; - $GLOBALS['TL_MODELS']['tl_banner'] = \HeimrichHannot\BannerPlusBundle\Model\BannerModel::class; $GLOBALS['TL_MODELS']['tl_banner_category'] = \HeimrichHannot\BannerPlusBundle\Model\BannerCategoryModel::class; diff --git a/src/Resources/contao/templates/banner/mod_banner_list_fireplace_ad.html5 b/src/Resources/contao/templates/banner/mod_banner_list_fireplace_ad.html5 index 1f545303..66a28de5 100644 --- a/src/Resources/contao/templates/banner/mod_banner_list_fireplace_ad.html5 +++ b/src/Resources/contao/templates/banner/mod_banner_list_fireplace_ad.html5 @@ -9,7 +9,7 @@