Fix settings bungle, update lib versions

pull/3124/head
Julio 5 years ago
parent 295371f367
commit 3bba40883b
  1. 32
      composer.json
  2. 4
      config/bundles.php
  3. 2
      config/packages/dev/jms_serializer.yaml
  4. 2
      config/packages/jms_serializer.yaml
  5. 3
      config/services.yaml
  6. 10
      src/CoreBundle/Controller/Admin/PluginsController.php
  7. 18
      src/CoreBundle/Controller/Admin/SettingsController.php
  8. 59
      src/CourseBundle/Manager/SettingsFormFactory.php
  9. 4
      src/CourseBundle/Resources/config/services.yml
  10. 14
      src/SettingsBundle/Manager/SettingsManager.php
  11. 11
      src/SettingsBundle/Resources/config/services.xml

@ -33,6 +33,12 @@
"public/main/survey"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/jmontoyaa/APYDataGridBundle.git"
}
],
"require": {
"php": "^7.2.5",
"ext-bcmath": "*",
@ -62,31 +68,31 @@
"sensio/framework-extra-bundle": "~5.0",
"sensiolabs/security-checker": "~6.0",
"symfony/asset": "^4.0",
"symfony/asset": "^4.0|^5.0",
"symfony/dotenv": "^4.0|^5.0",
"symfony/expression-language": "^4.0",
"symfony/flex": "^1.6",
"symfony/form": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/http-kernel": "^4.0",
"symfony/form": "^4.0|^5.0",
"symfony/framework-bundle": "^4.0|^5.0",
"symfony/http-kernel": "^4.0|^5.0",
"symfony/monolog-bundle": "^3.1",
"symfony/mailer": "^4.0|^5.0",
"symfony/polyfill-apcu": "^1.9",
"symfony/requirements-checker": "^1.1",
"symfony/security-bundle": "^4.0",
"symfony/security-bundle": "^4.0|^5.0",
"symfony/templating" : "^4.0",
"symfony/translation": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/twig-bundle": "^4.0|^5.0",
"symfony/validator": "^4.0",
"symfony/webpack-encore-bundle": "^1.7",
"symfony/yaml": "^4.0",
"symfony/yaml": "^4.0|^5.0",
"tgalopin/html-sanitizer-bundle": "^1.1",
"twig/extensions": "^1.5",
"symfony/apache-pack": "^1.0",
"apy/datagrid-bundle" : "dev-master",
"chamilo/settings-bundle": "1.*",
"chamilo/settings-bundle": "dev-master",
"sonata-project/admin-bundle": "~3.0",
"sonata-project/block-bundle": "~3.0",
"sonata-project/cache-bundle": "~2.0",
@ -110,7 +116,7 @@
"antishov/doctrine-extensions-bundle": "~1.4",
"sunra/php-simple-html-dom-parser": "~1.5.0",
"friendsofsymfony/jsrouting-bundle": "~2.0",
"gregwar/captcha-bundle": "^2.0",
"gregwar/captcha-bundle": "dev-master",
"knplabs/gaufrette": "~0.7",
"knplabs/doctrine-behaviors": "~1.6",
@ -147,7 +153,7 @@
"paragonie/random-lib": "~2.0",
"knplabs/knp-menu-bundle": "^2.0",
"liip/theme-bundle": "^1.6",
"liip/imagine-bundle": "^2.1",
"liip/imagine-bundle": "dev-master",
"a2lix/translation-form-bundle": "^3.0",
"oneup/uploader-bundle": "dev-master",
"overblog/graphql-bundle": "~0.11",
@ -208,11 +214,5 @@
"Chamilo\\CoreBundle\\Composer\\ScriptHandler::deleteOldFilesFrom19x"
],
"phpcs": "phpcs --standard=.php_cs.dist"
},
"extra": {
"symfony": {
"allow-contrib": true,
"require": "4.4.*"
}
}
}

@ -72,9 +72,5 @@ return [
Cocur\Slugify\Bridge\Symfony\CocurSlugifyBundle::class => ['all' => true],
KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true],
Translation\Bundle\TranslationBundle::class => ['all' => true],
winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true],
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
];

@ -1,6 +1,6 @@
jms_serializer:
visitors:
json:
json_serialization:
options:
- JSON_PRETTY_PRINT
- JSON_UNESCAPED_SLASHES

@ -1,6 +1,6 @@
jms_serializer:
visitors:
xml:
xml_serialization:
format_output: '%kernel.debug%'
# metadata:
# auto_detection: false

@ -58,9 +58,6 @@ services:
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
_instanceof:
Sylius\Bundle\ResourceBundle\Controller\ResourceController:
autowire: false
Chamilo\PageBundle\:
resource: '../src/PageBundle/*'

@ -58,8 +58,6 @@ class PluginsController extends SyliusSettingsController
}
$installedPlugins = $appPlugin->getInstalledPlugins();
//$manager = $this->getSettingsManager();
//$schemas = $manager->getSchemas();
return $this->render(
'@ChamiloTheme/Admin/Settings/pluginsAdd.html.twig',
@ -69,12 +67,4 @@ class PluginsController extends SyliusSettingsController
]
);
}
/**
* @return SettingsManager
*/
protected function getSettingsManager()
{
return $this->get('chamilo.settings.manager');
}
}

@ -7,18 +7,31 @@ namespace Chamilo\CoreBundle\Controller\Admin;
use Chamilo\SettingsBundle\Manager\SettingsManager;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sylius\Bundle\SettingsBundle\Controller\SettingsController as SyliusSettingsController;
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\Translation\Translator;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class SettingsController.
*/
class SettingsController extends SyliusSettingsController
{
public static function getSubscribedServices(): array
{
$services = parent::getSubscribedServices();
$services['chamilo.settings.manager'] = SettingsManager::class;
$services['chamilo_settings.form_factory.settings'] = SettingsFormFactory::class;
$services['translator'] = TranslatorInterface::class;
return $services;
}
/**
* @Security("has_role('ROLE_ADMIN')")
*
@ -205,6 +218,11 @@ class SettingsController extends SyliusSettingsController
return $this->get('chamilo.settings.manager');
}
protected function getSettingsFormFactory()
{
return $this->get('chamilo_settings.form_factory.settings');
}
/**
* @return \Symfony\Component\Form\FormInterface
*/

@ -0,0 +1,59 @@
<?php
namespace Chamilo\CourseBundle\Manager;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactoryInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaFormOptionsInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\FormFactoryInterface;
final class SettingsFormFactory implements SettingsFormFactoryInterface
{
/**
* @var ServiceRegistryInterface
*/
private $schemaRegistry;
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* @param ServiceRegistryInterface $schemaRegistry
* @param FormFactoryInterface $formFactory
*/
public function __construct(ServiceRegistryInterface $schemaRegistry, FormFactoryInterface $formFactory)
{
$this->schemaRegistry = $schemaRegistry;
$this->formFactory = $formFactory;
}
/**
* {@inheritdoc}
*/
public function create($schemaAlias, $data = null, array $options = [])
{
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);
if ($schema instanceof SchemaFormOptionsInterface) {
$options = array_merge($schema->getOptions(), $options);
}
$builder = $this->formFactory->createBuilder(
FormType::class,
$data,
array_merge_recursive(
['data_class' => null],
$options
)
);
$schema->buildForm($builder);
return $builder->getForm();
}
}

@ -14,13 +14,11 @@ services:
Chamilo\CourseBundle\Manager\SettingsManager:
arguments:
- '@chamilo_course.registry.settings_schema'
- '@sylius.registry.settings_resolver'
- '@doctrine.orm.entity_manager'
- '@chamilo_course.repository.parameter'
- '@sylius.factory.settings'
- '@event_dispatcher'
Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory:
Chamilo\CourseBundle\Manager\SettingsFormFactory:
arguments:
- '@chamilo_course.registry.settings_schema'
- '@form.factory'

@ -16,7 +16,6 @@ use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Exception\ValidatorException;
@ -72,17 +71,15 @@ class SettingsManager implements SettingsManagerInterface
*/
public function __construct(
ServiceRegistryInterface $schemaRegistry,
ServiceRegistryInterface $resolverRegistry,
EntityManager $manager,
EntityRepository $repository,
FactoryInterface $settingsFactory,
$eventDispatcher
) {
$this->schemaRegistry = $schemaRegistry;
$this->resolverRegistry = $resolverRegistry;
//$this->resolverRegistry = $resolverRegistry;
$this->manager = $manager;
$this->repository = $repository;
$this->settingsFactory = $settingsFactory;
//$this->settingsFactory = $settingsFactory;
$this->eventDispatcher = $eventDispatcher;
}
@ -682,7 +679,6 @@ class SettingsManager implements SettingsManagerInterface
{
$schemaAliasNoPrefix = $schemaAlias;
$schemaAlias = 'chamilo_core.settings.'.$schemaAlias;
if ($this->schemaRegistry->has($schemaAlias)) {
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);
@ -690,8 +686,7 @@ class SettingsManager implements SettingsManagerInterface
return [];
}
/** @var \Sylius\Bundle\SettingsBundle\Model\Settings $settings */
$settings = $this->settingsFactory->createNew();
$settings = new Settings();
$settings->setSchemaAlias($schemaAlias);
// We need to get a plain parameters array since we use the options resolver on it
@ -901,8 +896,7 @@ class SettingsManager implements SettingsManagerInterface
}
$persistedParametersMap[$name]->setValue($value);
} else {
/** @var SettingsCurrent $setting */
$setting = $this->settingsFactory->createNew();
$setting = new Settings();
$setting->setSchemaAlias($schemaAlias);
$setting

@ -20,16 +20,23 @@
<service id="chamilo.settings.manager" class="%chamilo_settings.settings.manager.class%" public="true" >
<argument type="service" id="sylius.registry.settings_schema" />
<argument type="service" id="sylius.registry.settings_resolver" />
<argument type="service" id="doctrine.orm.entity_manager" />
<argument type="service" id="chamilo_settings.repository" />
<argument type="service" id="sylius.factory.settings" />
<argument type="service" id="event_dispatcher" />
</service>
<service id="%chamilo_settings.settings.manager.class%" alias="chamilo.settings.manager">
</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" />
</service>
<service id="Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory" alias="chamilo_settings.form_factory.settings">
</service>
<service id="chamilo_settings.templating.helper.settings" class="%chamilo_settings.templating.helper.settings.class%" public="true">
<argument type="service" id="chamilo.settings.manager" />
<tag name="templating.helper" alias="chamilo_settings" />

Loading…
Cancel
Save