J4 Issue ?
avatar laoneo
laoneo
6 Feb 2018

As discussed in JAB17 we need a plan for the helper classes. At the moment they have the same setup as on J3 and are resting in the root namespace. These classes are mostly magically compiled somewhere outside of the extension itself. For example here is the Helper class of the component loaded and checked if the function exists. We need to have a look case by case how we want to solve it.

There are different ways to achieve that, we were discussing the following approaches:

  • Boot functionality of an extension to load its environment
  • Through Plugin events
  • Service provider for the DI container
  • ...

I add here a todo list of known cases where we need to find a solution for:

The list is by for not complete, the plan is to constantly extend it.

avatar laoneo laoneo - open - 6 Feb 2018
avatar joomla-cms-bot joomla-cms-bot - change - 6 Feb 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Feb 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Feb 2018
Category Components
avatar wilsonge wilsonge - change - 12 Feb 2018
The description was changed
avatar wilsonge wilsonge - edited - 12 Feb 2018
avatar wilsonge wilsonge - change - 12 Feb 2018
The description was changed
avatar wilsonge wilsonge - edited - 12 Feb 2018
avatar wilsonge wilsonge - change - 12 Feb 2018
The description was changed
avatar wilsonge wilsonge - edited - 12 Feb 2018
avatar wilsonge wilsonge - change - 12 Feb 2018
The description was changed
avatar wilsonge wilsonge - edited - 12 Feb 2018
avatar laoneo
laoneo - comment - 12 Feb 2018

Adding here comments what we do discus in the meeting:

// Loads the services in the DI container of the component
// Category model
public function doblabla(JCategories cat = null)
{
    if (!$cat)
    {
        $cat = ComponentHelper::boot($this->option)->get('JCategories');
    }
}

// ComponentHelper
public static function boot()
{
    $container = self::getComponentContainer()->getContainer(JFactory::getContainer());
}

Keys:

  • Associations
  • JCategories
  • Router
  • Dispatcher

Legacy container which loads categories and associations the old way.

avatar mbabker
mbabker - comment - 12 Feb 2018

use Joomla\CMS\Association\AssociationExtensionInterface;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Component\Router\RouterInterface;
use Joomla\CMS\Dispatcher\DispatcherInterface;

interface ComponentContainer
{
    /*
     * @return AssociationExtensionInterface|null
     * @todo Should support for this be in a separate interface?
     * @throws UnsupportedFeatureException
     */
    public function getAssociations(): ?AssociationExtensionInterface;

    /*
     * @return Categories|null
     * @todo Should support for this be in a separate interface?
     * @throws UnsupportedFeatureException
     */
    public function getCategories(): ?Categories;

    /*
     * @return DispatcherInterface
     * @todo This implies a component doesn't support 3.x structure, is this OK?  I'm not aware of there being a legacy dispatcher implementation similar to the MVC LegacyFactory.
     */
    public function getDispatcher(): DispatcherInterface;

    /*
     * @return RouterInterface|null
     * @todo Should support for this be in a separate interface? Not all components have frontend routing, i.e. com_contenthistory
     * @throws UnsupportedFeatureException
     */
    public function getRouter(): ?RouterInterface;
}
avatar laoneo
laoneo - comment - 13 Feb 2018

You mean that's basically the return value of the boot function?

avatar laoneo
laoneo - comment - 13 Feb 2018

Another question which arises, should not every extension be bootable, especially plugins?

avatar mbabker
mbabker - comment - 13 Feb 2018

The object that gets created by the boot function IMO should have that interface.

For now I would focus primarily on components here. Going back to the Symfony bundle and Laravel package comparison, our components fit that role and I'd use that extension type to sort things out first. Then we can work out what changes are needed to do something similar for modules, plugins, templates, etc.

avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Feb 2018
Status New Discussion
avatar laoneo laoneo - change - 5 Mar 2018
The description was changed
avatar laoneo laoneo - edited - 5 Mar 2018
avatar laoneo laoneo - change - 8 Mar 2018
The description was changed
avatar laoneo laoneo - edited - 8 Mar 2018
avatar laoneo laoneo - change - 8 Mar 2018
The description was changed
avatar laoneo laoneo - edited - 8 Mar 2018
avatar brianteeman brianteeman - change - 25 Mar 2018
Labels Added: J4 Issue
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar laoneo laoneo - change - 10 May 2018
The description was changed
avatar laoneo laoneo - edited - 10 May 2018
avatar laoneo laoneo - change - 10 May 2018
The description was changed
avatar laoneo laoneo - edited - 10 May 2018
avatar laoneo
laoneo - comment - 10 May 2018

Closing this one as the identified services are migrated to the component set up.

avatar laoneo laoneo - change - 10 May 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-05-10 12:55:00
Closed_By laoneo
avatar laoneo laoneo - close - 10 May 2018

Add a Comment

Login with GitHub to post a comment