Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[TwigBundle] Added priority to twig extensions#24777

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Brunty wants to merge12 commits intosymfony:masterfromBrunty:twig-environment-priority
Closed

[TwigBundle] Added priority to twig extensions#24777

Brunty wants to merge12 commits intosymfony:masterfromBrunty:twig-environment-priority

Conversation

@Brunty
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRDon't merge before the docs

Added priority to twig extensions in theTwigEnvironmentPass to control the order in which they're registered, similar to theTwigLoaderPass

Though, unsure on what priority to use as a default, and will PR docs when finalised.

foreach ($container->findTaggedServiceIds('twig.extension',true)as$id =>$attributes) {
$priority =isset($attributes[0]['priority']) ?$attributes[0]['priority'] :0;
$prioritizedLoaders[$priority][] =$id;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could this be replaced by using thePriorityTaggedServiceTrait?

Brunty reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@iltar done :)

@fabpot
Copy link
Member

Can you explain the use case for having priorities on extensions? I do understand the need for loaders, but I fail to see why we would need them for extensions.

@Brunty
Copy link
ContributorAuthor

@fabpot I was recently working on something and needed to overload a filter - I was lucky in that where I was registering it, it was after the previous one being registered (so as per docs here:https://twig.symfony.com/doc/2.x/advanced.html#overloading) but figured that might not always be the case.

@nicolas-grekasnicolas-grekas added this to the4.1 milestoneNov 1, 2017
foreach ($container->findTaggedServiceIds('twig.extension',true)as$id =>$attributes) {
$definition->addMethodCall('addExtension',array(newReference($id)));
foreach ($this->findAndSortTaggedServices('twig.extension',$container)as$extension) {
$definition->addMethodCall('addExtension',array(newReference($extension)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

$extension is already a reference so that this code could be simplified

Brunty and ramk42 reacted with thumbs up emoji
Copy link
Contributor

@ro0NLro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

needs a CHANGELOG entry i guess.

class TwigEnvironmentPassTestextends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
Copy link
Contributor

@ro0NLro0NLNov 18, 2017
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

for clarity i prefer/** @var Type */ thus inline. But not a blocker :) and im not sure we do that elsewhere anyway.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

AFAIK, we don't do much "inline" on properties.

@Brunty
Copy link
ContributorAuthor

@ro0NL will add a changelog entry now, what version should it go under?

@ro0NL
Copy link
Contributor

4.0.0 but there's a 4.4.0 entry already, i think it's a typo :)

@Brunty
Copy link
ContributorAuthor

@ro0NL I'll add a 4.0.0 section, want me to correct the 4.4.0 one to 4.0.0?

@ro0NL
Copy link
Contributor

think so. affects master only anyway.

@Brunty
Copy link
ContributorAuthor

@ro0NL - added changelog entry for you

-----

* removed`ContainerAwareRuntimeLoader`
* added priority to twig extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be added in a new entry for 4.1.0

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

4.4.0
4.1.0
-----
* added priority to twig extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Twig

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Changed


protectedfunctionsetUp()
{
$this->builder =$this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition','findTaggedServiceIds','setAlias','getDefinition'))->getMock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would not mock theContainerBuilder class

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

please do so :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@xabbuh done :)


4.1.0
-----
* added priority to Twig extensions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

missing blank line before

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Added :)

*/
private$pass;

protectedfunctionsetUp()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we don't need this method IMHO, better remove it and the corresponding properties

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done :)

@fabpot
Copy link
Member

Thank you@Brunty.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@xabbuhxabbuhxabbuh approved these changes

+2 more reviewers

@ro0NLro0NLro0NL approved these changes

@linaorilinaorilinaori left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

7 participants

@Brunty@fabpot@ro0NL@nicolas-grekas@linaori@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp