Skip to content
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

Closed
3 tasks done
covex-nn opened this issue Dec 25, 2017 · 10 comments
Closed
3 tasks done

Switch from Templating Component to Twig #456

covex-nn opened this issue Dec 25, 2017 · 10 comments

Comments

@covex-nn
Copy link
Contributor

covex-nn commented Dec 25, 2017

I believe Templating Component will be deprecated soon, see symfony/symfony#21035. So, i have a plan how to switch from Templating Component to Twig. The plan has 3 stages:

I will describe what are stages internally.

Stage 1

  1. Add symfony/templating and symfony/asset to composer.json

  2. Change all template names to Twig namespaced syntax from BundleNameBundle:directory:filename.html.twig to @BundleName/directory/filename.html.twig everywhere

  3. Create new empty interface Sonata\BlockBundle\Templating\EngineInterface extending Symfony\Bundle\FrameworkBundle\Templating\EngineInterface

  4. Create new empty class Sonata\BlockBundle\Templating\TemplateLocator extending Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator. Create new sonata.templating.locator service and deprecate this new class.

  5. Create class Sonata\BlockBundle\Templating\TemplateNameParser extending Symfony\Bundle\FrameworkBundle\Templating. Create new service sonata.templating.name_parser and deprecate this new class.

  6. Create new empty class Sonata\BlockBundle\Templating\TwigEngine extending Symfony\Bundle\TwigBundle\TwigEngine implemenging new interface Sonata\BlockBundle\Templating\EngineInterface. Create new service sonata.templating with sonata.templating.locator and sonata.templating.name_parser as arguments for its constructor.

  7. Change <argument type="service" id="templating"/> to <argument type="service" id="sonata.templating"/> everywhere in src/Resources/config/*.xml

Stage 2

  1. Update Sonata\BlockBundle\Templating\EngineInterface interface: copy body from Symfony\Bundle\FrameworkBundle\Templating\EngineInterface, remove extends and deprecate.

  2. Update Sonata\BlockBundle\Templating\TwigEngine class: copy and modify body from Symfony\Bridge\Twig\TwigEngine, remove all Templating Component references, remove extends and deprecate.

  3. Remove Sonata\BlockBundle\Templating\TemplateLocator class

  4. Remove Sonata\BlockBundle\Templating\TemplateNameParser class

  5. Remove extends from Sonata\BlockBundle\Templating\Helper\BlockHelper class, remove tag templating.helper from service, and deprecate the class

  6. Remove symfony/templating from composer.json

  7. Remove type hint for arguments Sonata\BlockBundle\Templating\EngineInterface everywhere, accept both Twig\Environment and Sonata\BlockBundle\Templating\EngineInterface

  8. Use twig service as an argument instead of sonata.templating

Stage 3

  1. Set type hint where it was removed in Stage 2, accept only Twig\Environment

  2. Remove Sonata\BlockBundle\Templating\EngineInterface interface

  3. Remove Sonata\BlockBundle\Templating\Helper\BlockHelper class

  4. Remove Sonata\BlockBundle\Templating\TwigEngine class

What do you think?

@greg0ire
Copy link
Contributor

Great work! One question : how can people avoid deprecations introduced in stage 1?

@covex-nn
Copy link
Contributor Author

covex-nn commented Dec 25, 2017

@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 framework. See TemplateLocator.php or TemplateNameParser.php - deprecation is just a "flag"

@greg0ire
Copy link
Contributor

OK great !

@core23
Copy link
Member

core23 commented Jan 16, 2018

Can you create a dev-kit issue with a checklist please @covex-nn ?

@covex-nn
Copy link
Contributor Author

@core23 unfortunately i do not know what is "dev-kit issue" =(

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)

@greg0ire
Copy link
Contributor

Yes that's exactly it

@covex-nn
Copy link
Contributor Author

@core23 @greg0ire done =)

@jordisala1991
Copy link
Member

@covex-nn can this issue be closed? this bundle is completed right?

@covex-nn
Copy link
Contributor Author

Yes, this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants