30
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2024-06-03 06:50:49 +00:00
weblinks/src/administrator/components/com_weblinks/services/provider.php

64 lines
2.7 KiB
PHP
Raw Normal View History

2019-08-19 20:47:59 +00:00
<?php
2023-05-18 16:45:59 +00:00
2019-08-19 20:47:59 +00:00
/**
* @package Joomla.Administrator
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
2023-05-18 16:45:59 +00:00
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
use Joomla\CMS\Association\AssociationExtensionInterface;
2019-08-19 20:47:59 +00:00
use Joomla\CMS\Categories\CategoryFactoryInterface;
2021-06-19 14:17:09 +00:00
use Joomla\CMS\Component\Router\RouterFactoryInterface;
2019-08-19 20:47:59 +00:00
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
2021-06-19 14:17:09 +00:00
use Joomla\CMS\Extension\Service\Provider\RouterFactory;
2021-06-20 11:25:20 +00:00
use Joomla\CMS\HTML\Registry;
2019-08-19 20:47:59 +00:00
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Weblinks\Administrator\Extension\WeblinksComponent;
use Joomla\Component\Weblinks\Administrator\Helper\AssociationsHelper;
2019-08-19 20:47:59 +00:00
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
2021-10-26 16:46:23 +00:00
* The weblinks service provider.
2019-08-19 20:47:59 +00:00
*
* @since 4.0.0
*/
2023-05-18 16:45:59 +00:00
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->set(AssociationExtensionInterface::class, new AssociationsHelper());
$componentNamespace = '\\Joomla\\Component\\Weblinks';
$container->registerServiceProvider(new CategoryFactory($componentNamespace));
$container->registerServiceProvider(new MVCFactory($componentNamespace));
$container->registerServiceProvider(new ComponentDispatcherFactory($componentNamespace));
$container->registerServiceProvider(new RouterFactory($componentNamespace));
$container->set(ComponentInterface::class, function (Container $container) {
$component = new WeblinksComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setRegistry($container->get(Registry::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
return $component;
});
}
2019-08-19 20:47:59 +00:00
};