Skip to content

Conversation

@laoneo
Copy link
Member

@laoneo laoneo commented May 10, 2018

Pull Request for Issue #19580.

Summary of Changes

The component router is available through the booted component instance when available as services.

Testing Instructions

  • Install sample data
  • Enable modern routing with no id's
  • Browse around on the front end through the articles

Expected result

SEF urls are generated without id's.

Actual result

SEF urls are generated without id's.

* @param DatabaseInterface $db The database object
*/
public function __construct($app = null, $menu = null)
public function __construct(CMSApplication $app, AbstractMenu $menu, Category $category, DatabaseInterface $db)
Copy link
Contributor

@wilsonge wilsonge May 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we don't need a factory - these are all defined classes - so we should just use the DIC's build method here rather than using a factory (https://github.com/joomla-framework/di/blob/master/src/Container.php#L182) - we only need a factory for when we have the magic configuration array's that the DIC doesn't understand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type of $app can be changed to SiteApplication and Category to Categories, but for the AbstractMenumenu we do not have a resource in the container.

…r/service

# Conflicts:
#	administrator/components/com_content/Extension/ContentComponent.php
@laoneo
Copy link
Member Author

laoneo commented May 31, 2018

Getting rid of the factory would also mean that we set a router in the component directly and do always return the same instance on $app->bootComponent('com_content')->createRouter(); (we should rename then the function to getRouter).

@wilsonge
Copy link
Contributor

and do always return the same instance on $app->bootComponent('com_content')->createRouter();

yes but you wrap it in an anonymous function so it's still lazy loaded

@laoneo
Copy link
Member Author

laoneo commented May 31, 2018

When you create the ContentComponent then you need an instance no callback. Have a look here, where we pass now the factory. I would love to do it without a factory, I tried different things but none worked to have it in a clean way.

@laoneo
Copy link
Member Author

laoneo commented Aug 23, 2018

I need to get this one merged to finish the service conversion of com_contact, com_newsfeeds and com_categories.

@mbabker
Copy link
Contributor

mbabker commented Aug 31, 2018 via email

@laoneo
Copy link
Member Author

laoneo commented Sep 13, 2018

Any more feedback?

@wilsonge wilsonge merged commit 465c1da into joomla:4.0-dev Oct 2, 2018
@wilsonge
Copy link
Contributor

wilsonge commented Oct 2, 2018

Thankyou!

@wilsonge wilsonge deleted the j4/router/service branch October 2, 2018 21:58
@wilsonge wilsonge added this to the Joomla 4.0 milestone Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants