File tree Expand file tree Collapse file tree 6 files changed +129
-23
lines changed
tests/System/integration/site/modules/mod_feed Expand file tree Collapse file tree 6 files changed +129
-23
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1111 <description >MOD_FEED_XML_DESCRIPTION</description >
1212 <namespace path =" src" >Joomla\Module\Feed</namespace >
1313 <files >
14- <filename module =" mod_feed" >mod_feed.php</ filename >
14+ <folder module =" mod_feed" >services</ folder >
1515 <folder >src</folder >
1616 <folder >tmpl</folder >
1717 </files >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @package Joomla.Site
5+ * @subpackage mod_feed
6+ *
7+ * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
8+ * @license GNU General Public License version 2 or later; see LICENSE.txt
9+ */
10+
11+ \defined ('_JEXEC ' ) or die;
12+
13+ use Joomla \CMS \Extension \Service \Provider \HelperFactory ;
14+ use Joomla \CMS \Extension \Service \Provider \Module ;
15+ use Joomla \CMS \Extension \Service \Provider \ModuleDispatcherFactory ;
16+ use Joomla \DI \Container ;
17+ use Joomla \DI \ServiceProviderInterface ;
18+
19+ /**
20+ * The feed module service provider.
21+ *
22+ * @since __DEPLOY_VERSION__
23+ */
24+ return new class () implements ServiceProviderInterface {
25+ /**
26+ * Registers the service provider with a DI container.
27+ *
28+ * @param Container $container The DI container.
29+ *
30+ * @return void
31+ *
32+ * @since __DEPLOY_VERSION__
33+ */
34+ public function register (Container $ container ): void
35+ {
36+ $ container ->registerServiceProvider (new ModuleDispatcherFactory ('\\Joomla \\Module \\Feed ' ));
37+ $ container ->registerServiceProvider (new HelperFactory ('\\Joomla \\Module \\Feed \\Site \\Helper ' ));
38+
39+ $ container ->registerServiceProvider (new Module ());
40+ }
41+ };
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @package Joomla.Site
5+ * @subpackage mod_feed
6+ *
7+ * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
8+ * @license GNU General Public License version 2 or later; see LICENSE.txt
9+ */
10+
11+ namespace Joomla \Module \Feed \Site \Dispatcher ;
12+
13+ use Joomla \CMS \Dispatcher \AbstractModuleDispatcher ;
14+ use Joomla \CMS \Helper \HelperFactoryAwareInterface ;
15+ use Joomla \CMS \Helper \HelperFactoryAwareTrait ;
16+
17+ // phpcs:disable PSR1.Files.SideEffects
18+ \defined ('_JEXEC ' ) or die;
19+ // phpcs:enable PSR1.Files.SideEffects
20+
21+ /**
22+ * Dispatcher class for mod_feed
23+ *
24+ * @since __DEPLOY_VERSION__
25+ */
26+ class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
27+ {
28+ use HelperFactoryAwareTrait;
29+
30+ /**
31+ * Returns the layout data.
32+ *
33+ * @return array
34+ *
35+ * @since __DEPLOY_VERSION__
36+ */
37+ protected function getLayoutData (): array
38+ {
39+ $ data = parent ::getLayoutData ();
40+
41+ $ data ['rssurl ' ] = $ data ['params ' ]->get ('rssurl ' , '' );
42+ $ data ['rssrtl ' ] = $ data ['params ' ]->get ('rssrtl ' , 0 );
43+ $ data ['feed ' ] = $ this ->getHelperFactory ()->getHelper ('FeedHelper ' )->getFeedInformation ($ data ['params ' ]);
44+
45+ return $ data ;
46+ }
47+ }
Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ class FeedHelper
3030 * @param \Joomla\Registry\Registry $params module parameters
3131 *
3232 * @return \Joomla\CMS\Feed\Feed|string
33+ *
34+ * @since __DEPLOY_VERSION__
3335 */
34- public static function getFeed ($ params )
36+ public function getFeedInformation ($ params )
3537 {
3638 // Module params
3739 $ rssurl = $ params ->get ('rssurl ' , '' );
@@ -52,4 +54,23 @@ public static function getFeed($params)
5254 return $ rssDoc ;
5355 }
5456 }
57+
58+ /**
59+ * Retrieve feed information
60+ *
61+ * @param \Joomla\Registry\Registry $params module parameters
62+ *
63+ * @return \Joomla\CMS\Feed\Feed|string
64+ *
65+ * @deprecated __DEPLOY_VERSION__ will be removed in 7.0
66+ * Use the non-static method getFeedInformation
67+ * Example: Factory::getApplication()->bootModule('mod_feed', 'site')
68+ * ->getHelper('FeedHelper')
69+ * ->getFeedInformation($params, Factory::getApplication())
70+ *
71+ */
72+ public static function getFeed ($ params )
73+ {
74+ return (new self ())->getFeedInformation ($ params );
75+ }
5576}
Original file line number Diff line number Diff line change 1+ describe ( 'Test in frontend that the feed module' , ( ) => {
2+ [ 'joomla.org' ] . forEach ( ( file ) => {
3+ it ( 'can display feed' , ( ) => {
4+ cy . db_createModule ( {
5+ title : 'automated test feed' ,
6+ module : 'mod_feed' ,
7+ params : `{"rssurl": "${ Cypress . config ( 'baseUrl' ) } /tests/System/data/com_newsfeeds/${ file } .xml" }` ,
8+ } )
9+ . then ( ( ) => {
10+ cy . visit ( '/' ) ;
11+
12+ cy . contains ( 'automated test feed' ) ;
13+ cy . get ( 'ul.newsfeed' ) . should ( 'exist' ) ;
14+ cy . get ( 'ul.newsfeed' ) . children ( ) . should ( 'have.length' , 3 ) ;
15+ } ) ;
16+ } ) ;
17+ } ) ;
18+ } ) ;
You can’t perform that action at this time.
0 commit comments