-
-
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
Use Templating Component without "templating" service #457
Conversation
Could you please rebase your PR and fix merge conflicts? |
Could you please rebase your PR and fix merge conflicts? |
Could you please rebase your PR and fix merge conflicts? |
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator as FrameworkTemplateLocator; | ||
|
||
/** | ||
* @deprecated since 3.9, to be removed with 4.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? its new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created new service sonata.templating
, to start migrating from templating
to twig
service without BC breaks in 3.x branch. sonata.templating
, like templating
service, has 3 arguments: twig
, sonata.templating.name_parser
and sonata.templating.locator
. This new class is sonata.templating.locator
service.
It is a new class, yes. It is needed in 3.x branch to be sure, that everything will be fine after deprecating of symfony/templating
component. But this new class should not be used by other services, because it will be deleted in master branch (if PR will be merged, of course) accordingly with stage 2 of a plan, described in #456
So, it is new and deprecated at the same time.
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser as FrameworkTemplateNameParser; | ||
|
||
/** | ||
* @deprecated since 3.9, to be removed with 4.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? its new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. But this class is sonata.templating.name_parser
service
Maybe this need to be done in CoreBundle? And then can be reused in other sonata bundles? |
@aLkRicha what do you mean by reused? This migrations needs to be done on all bundles, right? |
@jordisala1991 the second argument of So, we cannot just change |
@covex-nn please, answer my question |
@aLkRicha CoreBundle does not use So, BlockBundle is a right place for a new |
@covex-nn but you can remove the type hint, and check if the instance passed is a EngineInterface or TwigEnv.. and if not throw an exception.. and that is not BC break |
@jordisala1991 i used http://symfony.com/doc/current/contributing/code/bc.html to determine what change is allowed and what is not. Removing type hint of an argument of a public method is not allowed there. I thought it is a BC break. Anyway, removing type hint could be done only after all template references in all bundles will be guaranteed switched from "templating syntax" to "twig namespaced syntax", i.e. only in master branch, in next major release. But i hoped to run SonataAdminBundle with Flex with in 3.x branch. If "removing type hint of an argument" is not BC break, than my plan is not good enough, and there will be 2 stages, not 3. |
Wow, they really consider it bc break, althought we have done it several times, and I am not sure why they consider a bc break, because it does not break anything (if done correctly) . Wdyt @greg0ire? |
Removing the type hint of a method is a BC break for extending classes (they may only widen it). |
It throws a warning but it works, anyway if we consider it BC break we cannot do what I said. |
Warning are BC breaks... Even strict standards are. That's why classes / methods should be final |
I've updated issue #456, i added removing type hint for second argument of |
The build fails on php 7.0 |
I restarted the build, as it was a race condition 👍 |
do we really need there |
@aLkRicha we need it in 3.x branch, because Templating Component is still used. It will be removed in master branch, if this PR will be accepted |
@@ -11,7 +11,7 @@ | |||
|
|||
namespace Sonata\BlockBundle\Test; | |||
|
|||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | |||
use Sonata\BlockBundle\Templating\EngineInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only “use” that you are replacing even though there are more references to EngineInterface on the project. Dont we need to replace all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will replace all "use"s in master branch, if this PR will be accepted. Tests, that use Sonata\BlockBundle\Test\FakeTemplating
show us, that when we use templating service, implementing Sonata\BlockBundle\Templating\EngineInterface
, everything is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we use sonata.templating
instead of templating
!
sonata.templating
is Sonata\BlockBundle\Templating\TwigEngine
, it implements Sonata\BlockBundle\Templating\EngineInterface
.
Lets pull the trigger, great work @covex-nn |
@jordisala1991 please do not release it right now. I realized, that i should not remove tag from templating helper. Functions |
I've found, that it is not so important, but anyway removing <?php echo $view['sonata_block']->includeStylesheets('css/style.css'); ?> |
I am targeting this branch, because this is backward compatible feature.
See #456
Changelog
Subject
This is first step to switching from
Templating Component
to usingTwig
directly. The following two steps are described in #456. This PR will allow to runSonataBlockBundle
without activating templating extension inframework
.If this PR will be accepted, all other sonata bundles, that use SonataBlockBundle, could be updated too: services will have to use
sonata.templating
service instead oftemplating
and templates must be referenced using Twig namespaced syntax