-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.2] Introduce helper factory aware interface and convert news module to services #37445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
roland-d
merged 13 commits into
joomla:4.2-dev
from
Digital-Peak:j4/modules/articlenews
Apr 26, 2022
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
01c9bc8
Introduce helper factory aware interface and convert news module to s…
laoneo 13c1cf6
remove old file from manifest
laoneo 96462de
Back to helper
laoneo fea9544
cs
laoneo c7c1db6
Merge branch '4.2-dev' into j4/modules/articlenews
laoneo fc99c09
folder
laoneo 18efc25
Merge branch 'j4/modules/articlenews' of github.com:Digital-Peak/joom…
laoneo b081abe
Merge branch '4.2-dev' into j4/modules/articlenews
laoneo 5784918
Merge remote-tracking branch 'upstream/4.2-dev' into j4/modules/artic…
laoneo 3ee5c32
Inject the database
laoneo 676498f
Merge branch '4.2-dev' into j4/modules/articlenews
roland-d b7bffcd
Update libraries/src/Helper/HelperFactory.php
roland-d 8deda23
Merge branch '4.2-dev' into j4/modules/articlenews
roland-d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| <?php | ||
| /** | ||
| * Joomla! Content Management System | ||
| * | ||
| * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\CMS\Helper; | ||
|
|
||
| \defined('_JEXEC') or die; | ||
|
|
||
| /** | ||
| * Interface to be implemented by classes depending on a helper factory. | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| interface HelperFactoryAwareInterface | ||
| { | ||
| /** | ||
| * Sets the helper factory to use. | ||
| * | ||
| * @param HelperFactory $helper The helper factory to use. | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function setHelperFactory(HelperFactory $helper); | ||
| } |
This file contains hidden or 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,61 @@ | ||
| <?php | ||
| /** | ||
| * Joomla! Content Management System | ||
| * | ||
| * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\CMS\Helper; | ||
|
|
||
| \defined('_JEXEC') or die; | ||
|
|
||
| /** | ||
| * Defines the trait for a HelperFactory Aware Class. | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| trait HelperFactoryAwareTrait | ||
| { | ||
| /** | ||
| * HelperFactory | ||
| * | ||
| * @var HelperFactory | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| private $helperFactory; | ||
|
|
||
| /** | ||
| * Get the HelperFactory. | ||
| * | ||
| * @return HelperFactory | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| * | ||
| * @throws \UnexpectedValueException May be thrown if the HelperFactory has not been set. | ||
| */ | ||
| public function getHelperFactory(): HelperFactory | ||
| { | ||
| if ($this->helper) | ||
| { | ||
| return $this->helper; | ||
| } | ||
|
|
||
| throw new \UnexpectedValueException('HelperFactory not set in ' . __CLASS__); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the helper factory to use. | ||
| * | ||
| * @param HelperFactory $helperFactory The helper factory to use. | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function setHelperFactory(HelperFactory $helperFactory) | ||
| { | ||
| $this->helper = $helperFactory; | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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.Administrator | ||
| * @subpackage mod_articles_news | ||
| * | ||
| * @copyright (C) 2022 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 article news 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\\ArticlesNews')); | ||
| $container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\ArticlesNews\\Site\\Helper')); | ||
|
|
||
| $container->registerServiceProvider(new Module); | ||
| } | ||
| }; |
This file contains hidden or 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,42 @@ | ||
| <?php | ||
| /** | ||
| * @package Joomla.Site | ||
| * @subpackage mod_articles_news | ||
| * | ||
| * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\Module\ArticlesNews\Site\Dispatcher; | ||
|
|
||
| \defined('JPATH_PLATFORM') or die; | ||
|
|
||
| use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; | ||
| use Joomla\CMS\Helper\HelperFactoryAwareInterface; | ||
| use Joomla\CMS\Helper\HelperFactoryAwareTrait; | ||
|
|
||
| /** | ||
| * Dispatcher class for mod_articles_news | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface | ||
| { | ||
| use HelperFactoryAwareTrait; | ||
|
|
||
| /** | ||
| * Returns the layout data. | ||
| * | ||
| * @return array | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected function getLayoutData() | ||
| { | ||
| $data = parent::getLayoutData(); | ||
|
|
||
| $data['list'] = $this->getHelperFactory()->getHelper('ArticlesNewsHelper')->getArticles($data['params'], $this->getApplication()); | ||
|
|
||
| return $data; | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.