feat: add component service provider

This commit is contained in:
2026-06-27 20:21:45 +00:00
parent 0dc03eacc7
commit 3c59e6f2da
@@ -0,0 +1,41 @@
<?php
/**
* @copyright Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
* @license GPL-3.0-or-later
*/
defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
use Joomla\CMS\HTML\Registry;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Component\Router\RouterFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
return new class () implements ServiceProviderInterface {
public function register(Container $container): void
{
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Moko\\Component\\MokoSuiteBooking'));
$container->registerServiceProvider(new MVCFactory('\\Moko\\Component\\MokoSuiteBooking'));
$container->registerServiceProvider(new RouterFactory('\\Moko\\Component\\MokoSuiteBooking'));
$container->set(
ComponentInterface::class,
function (Container $container) {
$component = new \Joomla\CMS\Extension\MVCComponent();
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
$component->setRegistry($container->get(Registry::class));
$component->setDispatcherFactory($container->get(ComponentDispatcherFactoryInterface::class));
return $component;
}
);
}
};