This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
289 additions
and
70 deletions.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
src/CoreBundle/DependencyInjection/Compiler/FormCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Thomas Rabaix <[email protected]> | ||
* | ||
* @deprecated since sonata-project/core-bundle 3.x, to be removed in 4.0. | ||
*/ | ||
final class FormCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$this->registerDateAliases($container); | ||
$this->registerFormTypeAlias($container); | ||
$this->forceUserToMoveConfig($container); | ||
} | ||
|
||
private function registerDateAliases(ContainerBuilder $container) | ||
{ | ||
$container | ||
->setAlias('sonata.core.date.moment_format_converter', 'sonata.form.date.moment_format_converter') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.date.moment_format_converter" instead.' | ||
); | ||
} | ||
|
||
private function registerFormTypeAlias(ContainerBuilder $container) | ||
{ | ||
$container | ||
->setAlias('sonata.core.form.type.array', 'sonata.form.type.array') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.array" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.boolean', 'sonata.form.type.boolean') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.boolean" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.collection', 'sonata.form.type.collection') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.collection" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.date_range', 'sonata.form.type.date_range') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.date_range" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.datetime_range', 'sonata.form.type.datetime_range') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.datetime_range" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.date_picker', 'sonata.form.type.date_picker') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.date_picker" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.datetime_picker', 'sonata.form.type.datetime_picker') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.datetime_picker" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.date_range_picker', 'sonata.form.type.date_range_picker') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.date_range_picker" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.datetime_range_picker', 'sonata.form.type.datetime_range_picker') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.datetime_range_picker" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.form.type.equal', 'sonata.form.type.equal') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.form.type.equal" instead.' | ||
); | ||
} | ||
|
||
private function forceUserToMoveConfig(ContainerBuilder $container) | ||
{ | ||
$bundles = $container->getParameter('kernel.bundles'); | ||
|
||
if (!isset($bundles['SonataFormBundle'])) { | ||
return; | ||
} | ||
|
||
$defaultForm = [ | ||
'mapping' => [ | ||
'enabled' => true, | ||
'type' => [], | ||
'extension' => [], | ||
], | ||
]; | ||
$defaultSerializer = [ | ||
'formats' => [ | ||
0 => 'json', | ||
1 => 'xml', | ||
2 => 'yml', | ||
], | ||
]; | ||
|
||
if ($container->getParameter('sonata.core.form') !== $defaultForm) { | ||
throw new \Exception('Move bundle config from sonata_core.form to sonata_form.form'); | ||
} | ||
|
||
if ($container->getParameter('sonata.core.serializer') !== $defaultSerializer) { | ||
throw new \Exception('Move bundle config from sonata_core.serializer to sonata_form.serializer'); | ||
} | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
src/CoreBundle/DependencyInjection/Compiler/TwigCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* @author Thomas Rabaix <[email protected]> | ||
* | ||
* @deprecated since sonata-project/core-bundle 3.x, to be removed in 4.0. | ||
*/ | ||
final class TwigCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$this->registerFlashAliases($container); | ||
$this->registerTwigAliases($container); | ||
$this->forceUserToMoveConfig($container); | ||
} | ||
|
||
private function registerFlashAliases(ContainerBuilder $container) | ||
{ | ||
$container | ||
->setAlias('sonata.core.flashmessage.manager', 'sonata.twig.flashmessage.manager') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.manager" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.flashmessage.twig.runtime', 'sonata.twig.flashmessage.twig.runtime') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.twig.runtime" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.flashmessage.twig.extension', 'sonata.twig.flashmessage.twig.extension') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.twig.extension" instead.' | ||
); | ||
} | ||
|
||
private function registerTwigAliases(ContainerBuilder $container) | ||
{ | ||
$container | ||
->setAlias('sonata.core.twig.extension.wrapping', 'sonata.twig.extension.wrapping') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.extension.wrapping" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.twig.status_runtime', 'sonata.twig.status_runtime') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.status_runtime" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.twig.deprecated_template_extension', 'sonata.twig.deprecated_template_extension') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.deprecated_template_extension" instead.' | ||
); | ||
|
||
$container | ||
->setAlias('sonata.core.twig.template_extension', 'sonata.twig.template_extension') | ||
->setPublic(true) | ||
->setDeprecated( | ||
true, | ||
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.template_extension" instead.' | ||
); | ||
} | ||
|
||
private function forceUserToMoveConfig(ContainerBuilder $container) | ||
{ | ||
$bundles = $container->getParameter('kernel.bundles'); | ||
|
||
if (!isset($bundles['SonataTwigBundle'])) { | ||
return; | ||
} | ||
|
||
if (!empty($container->getParameter('sonata.core.flashmessage'))) { | ||
throw new \Exception('Move bundle config from sonata_core.flashmessage to sonata_twig.flashmessage'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<services> | ||
<service id="sonata.core.twig.extension.wrapping" alias="sonata.twig.extension.wrapping"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "%alias_id%" instead.</deprecated> | ||
</service> | ||
<service id="sonata.core.twig.extension.text" class="Sonata\CoreBundle\Twig\Extension\DeprecatedTextExtension"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0.</deprecated> | ||
<tag name="twig.extension"/> | ||
</service> | ||
<service id="sonata.core.twig.status_runtime" alias="sonata.twig.status_runtime"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "%alias_id%" instead.</deprecated> | ||
</service> | ||
<service id="sonata.core.twig.status_extension" class="Sonata\CoreBundle\Twig\Extension\StatusExtension"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.status_extension" instead.</deprecated> | ||
<tag name="twig.extension"/> | ||
</service> | ||
<service id="sonata.core.twig.deprecated_template_extension" alias="sonata.twig.deprecated_template_extension"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "%alias_id%" instead.</deprecated> | ||
</service> | ||
<service id="sonata.core.twig.template_extension" alias="sonata.twig.template_extension"> | ||
<deprecated>The "%service_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "%alias_id%" instead.</deprecated> | ||
</service> | ||
</services> | ||
</container> |
Oops, something went wrong.