Settings: Refactor settings manager service

pull/3965/head
Julio 3 years ago
parent 76fbc05868
commit 0dad0d454f
  1. 2
      src/CoreBundle/ChamiloCoreBundle.php
  2. 3
      src/CoreBundle/DataFixtures/AccessUserUrlFixtures.php
  3. 1
      src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php
  4. 2
      src/CoreBundle/Framework/Container.php
  5. 4
      src/CoreBundle/Resources/config/listeners.yml
  6. 13
      src/CoreBundle/Resources/config/services.xml
  7. 2
      src/CoreBundle/Resources/config/services.yml
  8. 16
      src/CoreBundle/Traits/ControllerTrait.php
  9. 11
      src/CourseBundle/Resources/config/services.yml

@ -6,7 +6,6 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle;
use Chamilo\CoreBundle\DependencyInjection\Compiler\ToolCompilerClass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
@ -15,6 +14,5 @@ class ChamiloCoreBundle extends Bundle
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new ToolCompilerClass());
}
}

@ -8,6 +8,7 @@ namespace Chamilo\CoreBundle\DataFixtures;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@ -60,7 +61,7 @@ class AccessUserUrlFixtures extends Fixture implements ContainerAwareInterface
$this->addReference(AccessUserFixtures::ACCESS_URL_REFERENCE, $accessUrl);
$settingsManager = $container->get('chamilo.settings.manager');
$settingsManager = $container->get(SettingsManager::class);
$settingsManager->installSchemas($accessUrl);
$manager->flush();

@ -21,7 +21,6 @@ class ChamiloCoreExtension extends Extension
);
$loader->load('services.yml');
//$loader->load('tools.yml');
$loader->load('settings.yml');
$loader->load('repositories.yml');
$loader->load('tool_settings.yml');

@ -237,7 +237,7 @@ class Container
public static function getSettingsManager(): SettingsManager
{
return self::$container->get('chamilo.settings.manager');
return self::$container->get(SettingsManager::class);
}
public static function getCourseSettingsManager(): SettingsCourseManager

@ -64,7 +64,7 @@ services:
# Auth listeners
Chamilo\CoreBundle\EventListener\LoginSuccessHandler:
arguments: ['@router', '@security.authorization_checker', 'Chamilo\CoreBundle\Settings\SettingsManager']
arguments: ['@router', '@security.authorization_checker', '@Chamilo\CoreBundle\Settings\SettingsManager']
tags:
- {name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin}
@ -99,7 +99,7 @@ services:
# When the Course entity is created/updated
Chamilo\CoreBundle\Entity\Listener\CourseListener:
arguments: ['@Chamilo\CoreBundle\Tool\ToolChain', 'Chamilo\CoreBundle\Settings\SettingsManager']
arguments: ['@Chamilo\CoreBundle\Tool\ToolChain', '@Chamilo\CoreBundle\Settings\SettingsManager']
tags:
- {name: doctrine.orm.entity_listener, entity_manager: default, lazy: true}

@ -3,20 +3,7 @@
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="chamilo_settings.settings.manager.class">Chamilo\CoreBundle\Settings\SettingsManager</parameter>
<parameter key="chamilo_settings.repository.parameter.entity.class">Chamilo\CoreBundle\Entity\SettingsCurrent</parameter>
<parameter key="chamilo_settings.twig.extension.settings.class">Chamilo\CoreBundle\Twig\SettingsExtension</parameter>
<parameter key="chamilo_settings.templating.helper.settings.class">Chamilo\CoreBundle\Twig\SettingsHelper</parameter>
</parameters>
<services>
<service id="chamilo_settings.repository" class="Doctrine\ORM\EntityRepository">
<factory service="doctrine.orm.entity_manager" method="getRepository" />
<argument>%chamilo_settings.repository.parameter.entity.class%</argument>
</service>
<service id="chamilo_settings.form_factory.settings" public="true" class="Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory">
<argument type="service" id="sylius.registry.settings_schema" />
<argument type="service" id="form.factory" />

@ -70,7 +70,7 @@ services:
arguments:
- '@sylius.registry.settings_schema'
- '@doctrine.orm.entity_manager'
- '@chamilo_settings.repository'
- '@Chamilo\CoreBundle\Repository\SettingsCurrentRepository'
- '@event_dispatcher'
- '@request_stack'

@ -48,12 +48,13 @@ trait ControllerTrait
$services = AbstractController::getSubscribedServices();
$services['translator'] = TranslatorInterface::class;
$services['glide'] = Glide::class;
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class;
//$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class;
$services[] = SettingsManager::class;
$services[] = MessageAttachmentRepository::class;
$services[] = ResourceFactory::class;
$services[] = ResourceNodeRepository::class;
$services[] = SettingsFormFactory::class;
/*
The following classes are needed in order to load the resources files when using the /r/ path
@ -81,16 +82,12 @@ trait ControllerTrait
$services[] = CStudentPublicationCommentRepository::class;
$services[] = CStudentPublicationCorrectionRepository::class;
$services[] = ExternalToolRepository::class;
$services[] = IllustrationRepository::class;
return $services;
}
/**
* @return Request|null
*/
public function getRequest()
public function getRequest(): ?Request
{
return $this->container->get('request_stack')->getCurrentRequest();
}
@ -126,16 +123,13 @@ trait ControllerTrait
return $this->container->get('doctrine')->getRepository(AccessUrl::class)->find($urlId);
}
/**
* @return SettingsManager
*/
protected function getSettingsManager()
protected function getSettingsManager(): SettingsManager
{
return $this->container->get(SettingsManager::class);
}
protected function getSettingsFormFactory()
{
return $this->container->get('chamilo_settings.form_factory.settings');
return $this->container->get(SettingsFormFactory::class);
}
}

@ -3,14 +3,15 @@ services:
autowire: true
public: true
Sylius\Bundle\SettingsBundle\Registry\ServiceRegistry:
chamilo_course.registry.settings_schema:
class: Sylius\Bundle\SettingsBundle\Registry\ServiceRegistry
arguments:
- Sylius\Bundle\SettingsBundle\Schema\SchemaInterface
- 'CourseSettings'
- 'Sylius\Bundle\SettingsBundle\Schema\SchemaInterface'
- 'Course settings schema'
Chamilo\CourseBundle\Settings\SettingsCourseManager:
arguments:
- '@Sylius\Bundle\SettingsBundle\Registry\ServiceRegistry'
- '@chamilo_course.registry.settings_schema'
- '@doctrine.orm.entity_manager'
- '@Chamilo\CourseBundle\Repository\CCourseSettingRepository'
- '@event_dispatcher'
@ -18,7 +19,7 @@ services:
Chamilo\CourseBundle\Settings\SettingsFormFactory:
arguments:
- 'Sylius\Bundle\SettingsBundle\Registry\ServiceRegistry'
- '@chamilo_course.registry.settings_schema'
- '@form.factory'
public: true

Loading…
Cancel
Save