-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert mod_tags_popular to service provider
- Loading branch information
1 parent
75fca46
commit 1d95c6f
Showing
5 changed files
with
145 additions
and
37 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_tags_popular | ||
* | ||
* @copyright (C) 2024 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 popular tags 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) | ||
{ | ||
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\TagsPopular')); | ||
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\TagsPopular\\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,72 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Site | ||
* @subpackage mod_tags_popular | ||
* | ||
* @copyright (C) 2024 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\Module\TagsPopular\Site\Dispatcher; | ||
|
||
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; | ||
use Joomla\CMS\Helper\HelperFactoryAwareInterface; | ||
use Joomla\CMS\Helper\HelperFactoryAwareTrait; | ||
use Joomla\CMS\Helper\ModuleHelper; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
\defined('_JEXEC') or die; | ||
// phpcs:enable PSR1.Files.SideEffects | ||
|
||
/** | ||
* Dispatcher class for mod_tags_popular | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface | ||
{ | ||
use HelperFactoryAwareTrait; | ||
|
||
/** | ||
* Runs the dispatcher. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function dispatch() | ||
{ | ||
$displayData = $this->getLayoutData(); | ||
|
||
if (!\count($displayData['list']) && !$displayData['params']->get('no_results_text')) { | ||
return; | ||
} | ||
|
||
parent::dispatch(); | ||
} | ||
|
||
/** | ||
* Returns the layout data. | ||
* | ||
* @return array | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
protected function getLayoutData() | ||
{ | ||
$data = parent::getLayoutData(); | ||
|
||
$cacheparams = new \stdClass(); | ||
$cacheparams->cachemode = 'safeuri'; | ||
$cacheparams->class = $this->getHelperFactory()->getHelper('TagsPopularHelper'); | ||
$cacheparams->method = 'getTags'; | ||
$cacheparams->methodparams = $data['params']; | ||
$cacheparams->modeparams = ['id' => 'array', 'Itemid' => 'int']; | ||
|
||
$data['list'] = ModuleHelper::moduleCache($this->module, $data['params'], $cacheparams); | ||
$data['display_count'] = $data['params']->get('display_count', 0); | ||
|
||
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