Internal: Fix course settings manager

pull/3451/head
Julio Montoya 4 years ago
parent efcbbc665c
commit 1b7a176d28
  1. 27
      src/CoreBundle/Controller/Admin/SettingsController.php
  2. 5
      src/CoreBundle/Controller/CourseHomeController.php
  3. 22
      src/CoreBundle/DependencyInjection/Configuration.php
  4. 1
      src/CoreBundle/EventListener/CourseListener.php
  5. 2
      src/CoreBundle/Resources/views/Course/settings.html.twig
  6. 17
      src/CoreBundle/Traits/ControllerTrait.php
  7. 1
      src/CourseBundle/Manager/SettingsManager.php
  8. 2
      src/CourseBundle/Resources/config/services.yml

@ -5,17 +5,14 @@
namespace Chamilo\CoreBundle\Controller\Admin;
use Chamilo\CoreBundle\Controller\BaseController;
use Chamilo\CoreBundle\Manager\SettingsManager;
use Chamilo\CoreBundle\Traits\ControllerTrait;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @Route("/admin")
@ -24,17 +21,6 @@ class SettingsController extends BaseController
{
use ControllerTrait;
public static function getSubscribedServices(): array
{
$services = parent::getSubscribedServices();
$services['translator'] = TranslatorInterface::class;
$services['chamilo.settings.manager'] = SettingsManager::class;
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class;
return $services;
}
/**
* @IsGranted("ROLE_ADMIN")
*
@ -213,19 +199,6 @@ class SettingsController extends BaseController
$manager->installSchemas($url);
}
/**
* @return SettingsManager
*/
protected function getSettingsManager()
{
return $this->get('chamilo.settings.manager');
}
protected function getSettingsFormFactory()
{
return $this->get('chamilo_settings.form_factory.settings');
}
/**
* @return \Symfony\Component\Form\FormInterface
*/

@ -21,7 +21,7 @@ use ExtraFieldValue;
use Fhaculty\Graph\Graph;
use Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Chamilo\CourseBundle\Manager\SettingsFormFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -242,8 +242,8 @@ class CourseHomeController extends ToolBaseController
public function updateAction(Request $request, Course $course, $namespace, SettingsManager $manager, SettingsFormFactory $formFactory)
{
$schemaAlias = $manager->convertNameSpaceToService($namespace);
$settings = $manager->load($namespace);
$form = $formFactory->create($schemaAlias);
$form->setData($settings);
@ -273,6 +273,7 @@ class CourseHomeController extends ToolBaseController
return $this->redirect($request->headers->get('referer'));
}
}
$schemas = $manager->getSchemas();
return $this->render(

@ -1,22 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files.
*
* To learn more see.
* {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
return new TreeBuilder('chamilo_settings');
}
}

@ -6,7 +6,6 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;

@ -19,7 +19,7 @@
{{ form_errors(form) }}
<form
class="form-horizontal"
action="{{ path('chamilo_core_course_settings', { 'namespace': namespace, 'keyword': keyword, 'cid' : course.id } ) }}"
action="{{ path('chamilo_core_course_settings', { 'namespace': namespace, 'cid' : course.id } ) }}"
method="post"
novalidate
>

@ -6,8 +6,10 @@ namespace Chamilo\CoreBundle\Traits;
//use Chamilo\CoreBundle\Block\BreadcrumbBlockService;
use Chamilo\CoreBundle\Component\Utils\Glide;
use Chamilo\CoreBundle\Manager\SettingsManager;
use Chamilo\CoreBundle\Repository\ResourceFactory;
use Knp\Menu\FactoryInterface as MenuFactoryInterface;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -21,6 +23,8 @@ trait ControllerTrait
//$services['breadcrumb'] = BreadcrumbBlockService::class;
$services['resource_factory'] = ResourceFactory::class;
$services['glide'] = Glide::class;
$services['chamilo.settings.manager'] = SettingsManager::class;
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class;
return $services;
}
@ -70,4 +74,17 @@ trait ControllerTrait
return $translator->trans($variable);
}
/**
* @return SettingsManager
*/
protected function getSettingsManager()
{
return $this->get('chamilo.settings.manager');
}
protected function getSettingsFormFactory()
{
return $this->get('chamilo_settings.form_factory.settings');
}
}

@ -40,7 +40,6 @@ class SettingsManager extends ChamiloSettingsManager
{
$schemaAliasNoPrefix = $schemaAlias;
$schemaAlias = 'chamilo_course.settings.'.$schemaAlias;
if ($this->schemaRegistry->has($schemaAlias)) {
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);

@ -7,7 +7,7 @@ services:
class: Sylius\Component\Registry\ServiceRegistry
arguments:
- Sylius\Bundle\SettingsBundle\Schema\SchemaInterface
- 'Course settings'
- 'CourseSettings'
Chamilo\CourseBundle\Manager\SettingsManager:
arguments:

Loading…
Cancel
Save