-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from Templating Component to Twig #456
Comments
Great work! One question : how can people avoid deprecations introduced in stage 1? |
@greg0ire deprecations will be only in comments, without trigger_error, these classes were created just for a case if services of parent classes will be unavailable when templating extension is not activated in |
OK great ! |
Can you create a |
@core23 unfortunately i do not know what is " Did you mean issue in https://github.com/sonata-project/dev-kit/ ? After merge and release #457 i planned to create PR "[WIP] Stage 2" here, in SonataBlockBundle repository, with a checklist (and to remove [WIP] prefix after all checks) |
Yes that's exactly it |
@covex-nn can this issue be closed? this bundle is completed right? |
Yes, this issue can be closed |
I believe
Templating Component
will be deprecated soon, see symfony/symfony#21035. So, i have a plan how to switch fromTemplating Component
toTwig
. The plan has 3 stages:Stage 1
, stable branch3.x
: UseTemplating Component
withouttemplating
service and with own classes for templating.See Use Templating Component without "templating" service #457 and Decouple sonata-project bundles from Templating Component, Stage 1 dev-kit#380
Stage 2
,master
branch: Remove usage ofTemplating Component
in code, and useTwig
directly or own classes for templatingStage 3
, futuremaster
branch: remove proxy classes for templating.I will describe what are stages internally.
Stage 1
Add
symfony/templating
andsymfony/asset
to composer.jsonChange all template names to Twig namespaced syntax from
BundleNameBundle:directory:filename.html.twig
to@BundleName/directory/filename.html.twig
everywhereCreate new empty interface
Sonata\BlockBundle\Templating\EngineInterface
extendingSymfony\Bundle\FrameworkBundle\Templating\EngineInterface
Create new empty class
Sonata\BlockBundle\Templating\TemplateLocator
extendingSymfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator
. Create newsonata.templating.locator
service and deprecate this new class.Create class
Sonata\BlockBundle\Templating\TemplateNameParser
extendingSymfony\Bundle\FrameworkBundle\Templating
. Create new servicesonata.templating.name_parser
and deprecate this new class.Create new empty class
Sonata\BlockBundle\Templating\TwigEngine
extendingSymfony\Bundle\TwigBundle\TwigEngine
implemenging new interfaceSonata\BlockBundle\Templating\EngineInterface
. Create new servicesonata.templating
withsonata.templating.locator
andsonata.templating.name_parser
as arguments for its constructor.Change
<argument type="service" id="templating"/>
to<argument type="service" id="sonata.templating"/>
everywhere insrc/Resources/config/*.xml
Stage 2
Update
Sonata\BlockBundle\Templating\EngineInterface
interface: copy body fromSymfony\Bundle\FrameworkBundle\Templating\EngineInterface
, removeextends
and deprecate.Update
Sonata\BlockBundle\Templating\TwigEngine
class: copy and modify body fromSymfony\Bridge\Twig\TwigEngine
, remove all Templating Component references, remove extends and deprecate.Remove
Sonata\BlockBundle\Templating\TemplateLocator
classRemove
Sonata\BlockBundle\Templating\TemplateNameParser
classRemove
extends
fromSonata\BlockBundle\Templating\Helper\BlockHelper
class, remove tagtemplating.helper
from service, and deprecate the classRemove
symfony/templating
from composer.jsonRemove type hint for arguments
Sonata\BlockBundle\Templating\EngineInterface
everywhere, accept bothTwig\Environment
andSonata\BlockBundle\Templating\EngineInterface
Use
twig
service as an argument instead ofsonata.templating
Stage 3
Set type hint where it was removed in Stage 2, accept only
Twig\Environment
Remove
Sonata\BlockBundle\Templating\EngineInterface
interfaceRemove
Sonata\BlockBundle\Templating\Helper\BlockHelper
classRemove
Sonata\BlockBundle\Templating\TwigEngine
classWhat do you think?
The text was updated successfully, but these errors were encountered: