Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.1] Convert mod_banners to service provider
- Loading branch information
Showing
5 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Site | ||
* @subpackage mod_banners | ||
* | ||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
\defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Extension\Service\Provider\HelperFactory; | ||
use Joomla\CMS\Extension\Service\Provider\Module; | ||
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory; | ||
use Joomla\DI\Container; | ||
use Joomla\DI\ServiceProviderInterface; | ||
|
||
/** | ||
* The banners module service provider. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
return new class () implements ServiceProviderInterface { | ||
/** | ||
* Registers the service provider with a DI container. | ||
* | ||
* @param Container $container The DI container. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function register(Container $container): void | ||
{ | ||
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\Banners')); | ||
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\Banners\\Site\\Helper')); | ||
|
||
$container->registerServiceProvider(new Module()); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Site | ||
* @subpackage mod_banners | ||
* | ||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\Module\Banners\Site\Dispatcher; | ||
|
||
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; | ||
use Joomla\CMS\Helper\HelperFactoryAwareInterface; | ||
use Joomla\CMS\Helper\HelperFactoryAwareTrait; | ||
use Joomla\Component\Banners\Administrator\Helper\BannersHelper as BannersComponentHelper; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
\defined('_JEXEC') or die; | ||
// phpcs:enable PSR1.Files.SideEffects | ||
|
||
/** | ||
* Dispatcher class for mod_banners | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface | ||
{ | ||
use HelperFactoryAwareTrait; | ||
|
||
/** | ||
* Returns the layout data. | ||
* | ||
* @return array | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
protected function getLayoutData(): array | ||
{ | ||
BannersComponentHelper::updateReset(); | ||
|
||
$data = parent::getLayoutData(); | ||
|
||
$data['headerText'] = trim($data['params']->get('header_text', '')); | ||
$data['footerText'] = trim($data['params']->get('footer_text', '')); | ||
$data['list'] = $this->getHelperFactory()->getHelper('BannersHelper')->getBanners($data['params'], $this->getApplication()); | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters