-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[5.1] Convert mod_feed to service provider #42215
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c7773b9
[5.1] Convert mod_feed to service provider
heelc29 5736331
Merge branch '5.1-dev' into 5.1/modules/site/feed
LadySolveig 9e552c8
Merge branch '5.1-dev' into 5.1/modules/site/feed
heelc29 31ee28d
Merge branch '5.1-dev' into 5.1/modules/site/feed
LadySolveig 135ec22
Merge branch '5.1-dev' into 5.1/modules/site/feed
LadySolveig ad53a80
Deprecate static function getFeed() and replace with non static function
LadySolveig 48a5f54
Merge pull request #1 from LadySolveig/heelc29/5.1/modules/site/feed
heelc29 e8696ac
Merge branch '5.1-dev' into 5.1/modules/site/feed
QuyTon c797119
Merge branch '5.1-dev' into 5.1/modules/site/feed
QuyTon 443c1a1
Merge branch '5.1-dev' into 5.1/modules/site/feed
QuyTon 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 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.Site | ||
| * @subpackage mod_feed | ||
| * | ||
| * @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 feed 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\\Feed')); | ||
| $container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\Feed\\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,47 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @package Joomla.Site | ||
| * @subpackage mod_feed | ||
| * | ||
| * @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\Feed\Site\Dispatcher; | ||
|
|
||
| use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; | ||
| use Joomla\CMS\Helper\HelperFactoryAwareInterface; | ||
| use Joomla\CMS\Helper\HelperFactoryAwareTrait; | ||
|
|
||
| // phpcs:disable PSR1.Files.SideEffects | ||
| \defined('_JEXEC') or die; | ||
| // phpcs:enable PSR1.Files.SideEffects | ||
|
|
||
| /** | ||
| * Dispatcher class for mod_feed | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface | ||
| { | ||
| use HelperFactoryAwareTrait; | ||
|
|
||
| /** | ||
| * Returns the layout data. | ||
| * | ||
| * @return array | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected function getLayoutData(): array | ||
| { | ||
| $data = parent::getLayoutData(); | ||
|
|
||
| $data['rssurl'] = $data['params']->get('rssurl', ''); | ||
| $data['rssrtl'] = $data['params']->get('rssrtl', 0); | ||
| $data['feed'] = $this->getHelperFactory()->getHelper('FeedHelper')->getFeedInformation($data['params']); | ||
|
|
||
| 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
18 changes: 18 additions & 0 deletions
18
tests/System/integration/site/modules/mod_feed/Default.cy.js
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,18 @@ | ||
| describe('Test in frontend that the feed module', () => { | ||
| ['joomla.org'].forEach((file) => { | ||
| it('can display feed', () => { | ||
| cy.db_createModule({ | ||
| title: 'automated test feed', | ||
| module: 'mod_feed', | ||
| params: `{"rssurl": "${Cypress.config('baseUrl')}/tests/System/data/com_newsfeeds/${file}.xml" }`, | ||
| }) | ||
| .then(() => { | ||
| cy.visit('/'); | ||
|
|
||
| cy.contains('automated test feed'); | ||
| cy.get('ul.newsfeed').should('exist'); | ||
| cy.get('ul.newsfeed').children().should('have.length', 3); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
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.