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] Commands as a service#23519

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
ro0NL wants to merge6 commits intosymfony:3.4fromro0NL:twig/commands
Closed

[TwigBundle] Commands as a service#23519

ro0NL wants to merge6 commits intosymfony:3.4fromro0NL:twig/commands

Conversation

@ro0NL
Copy link
Contributor

@ro0NLro0NL commentedJul 15, 2017
edited
Loading

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#...
LicenseMIT
Doc PRsymfony/symfony-docs#...

tiny step towards#23488

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

Can we keep a legacy test for theLintCommand?


/**
*{@inheritdoc}
*@param Environment|string $twig
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 make the old type an accepted one, onlyEnvironment

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That's for bc :) we can keep it out of phpdoc though..?

Copy link
Member

@chalasrchalasrJul 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

Yes guessed it, I think the doc should reflect the new behavior only (I might be wrong)

<serviceid="console.command.symfony_bundle_twigbundle_command_debugcommand"class="Symfony\Bridge\Twig\Command\DebugCommand">
<argumenttype="service"id="twig"/>
<tagname="console.command"command="debug:twig" />
</service>
Copy link
Member

Choose a reason for hiding this comment

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

deprecated="..."?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Not sure.. it's still picked up as the ought to be command service.

Perhaps if we do it vice versa; we can deprecate the alias. However tried that and it didnt work out causing auto discovery to override i believe.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, this service and alias don't exist in 3.3 and lower? Since the command wasn't registered as a service but through convention

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It's done to satisfythis check.

The deprecated command (in the bundle) will override (by command name) otherwise, as we dont skip deprecated commands here ;-) Note the new service points to the command in the bridge.

Copy link
Member

Choose a reason for hiding this comment

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

What about makingTwigBundle::registerCommands() a noop instead?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hehe 👍 could be a final resort. Shouldnt we add service aliases to the command map instead?

Copy link
Member

Choose a reason for hiding this comment

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

Addingconsole.command.symfony_bundle_twigbundle_command_debugcommand => false to theconsole.command.ids parameter? That's probably better regarding BC

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed!<defaults public="false" /> bite me :). The alias is now public and picked up. See console.xml

Copy link
Member

Choose a reason for hiding this comment

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

Still, it means that the dependencies of this command won't be loaded lazily anymore until 4.0 (the twig environment), that might break some consoles :)

Copy link
ContributorAuthor

@ro0NLro0NLJul 18, 2017
edited
Loading

Choose a reason for hiding this comment

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

Right.. i also realized i deprecated the alias, which probably wont work. We cant deprecate aliases. Although current XML is happily parsed.

So we basically need to preserve the old service (not as an alias). It will point to the old class and its definition is deprecated.

I believe that will conflict with auto discovery (deprecated will override), perhaps make a special case there. But i havent followed the code path for this approach yet.. maybe it just works :)

edit:

What about making TwigBundle::registerCommands() a noop instead?

Is probably the easiest indeed 👍

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneJul 17, 2017
@ro0NL
Copy link
ContributorAuthor

ro0NL commentedJul 18, 2017
edited
Loading

Legacy test added.@chalasr seems we donthave to make registerCommands a noop. It works as expected, the legacy command is not auto-discovered due its public service id.

This should be good to go :)

chalasr reacted with thumbs up emoji


/**
*{@inheritdoc}
*@param Environment $name

Choose a reason for hiding this comment

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

this should be future proof, ie the arg should be named $twig


/**
*{@inheritdoc}
*@param Environment $name

Choose a reason for hiding this comment

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

$twig

Copy link
Member

@chalasrchalasr left a comment

Choose a reason for hiding this comment

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

CHANGELOG/UPGRADE files need to be updated

@ro0NL
Copy link
ContributorAuthor

Done. Tedious job, that is :)

*{@inheritdoc}
*@param Environment $twig
*/
publicfunction__construct($name ='debug:twig')
Copy link
Contributor

Choose a reason for hiding this comment

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

- public function __construct($name = 'debug:twig')+ public function __construct($twig = 'debug:twig')

?

Copy link
ContributorAuthor

@ro0NLro0NLJul 19, 2017
edited
Loading

Choose a reason for hiding this comment

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

Not sure.. did that initially. But given we dont have to change it, this would be safest. So for BC really :)

edit: might look weird compared to phpdoc; although intended to clarify 4.0 sig. Perhaps the variable naming should be consistent here.. being either $twig or $name.. i dont mind.

@nicolas-grekas wdyt?

Choose a reason for hiding this comment

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

doc block and arg must have the same name for sure,
then I suggest $twig because that's the most future oriented, even if the default value looks strange.
One way to make it better would be to have null as default, and internally turn null into this string, in the deprecated code path. Might be the best in fact. (Same for the other command of course).

ogizanagi and chalasr reacted with thumbs up emoji
Copy link
ContributorAuthor

@ro0NLro0NLJul 20, 2017
edited
Loading

Choose a reason for hiding this comment

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

i preserved the sig for BC.. but thats from a reflection sniffing perspective. Which is nonsense i guess :)

__construct($twig = null) it is then 👍

*{@inheritdoc}
*@param Environment $twig
*/
publicfunction__construct($name ='lint:twig')
Copy link
Contributor

Choose a reason for hiding this comment

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

$twig


/**
*{@inheritdoc}
*@param Environment $twig
Copy link
Member

Choose a reason for hiding this comment

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

$name?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Patched.

* The`ContainerAwareRuntimeLoader` class has been removed. Use the
Twig`Twig_ContainerRuntimeLoader` class instead.

* Removed`ContainerAwareInterface` implementation in`Symfony\Bundle\TwigBundle\Command\LintCommand`
Copy link
Member

Choose a reason for hiding this comment

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

this is missing theDebugCommand class removal

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Right! nice catch.

if (!$twiginstanceof Environment) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.',__METHOD__),E_USER_DEPRECATED);

$this->setName(null ===$twig ?'debug:twig' :$twig);
Copy link
Contributor

@ogizanagiogizanagiJul 21, 2017
edited
Loading

Choose a reason for hiding this comment

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

Minor, but it looks safe to me to simply use$this->setName($twig ?: 'debug:twig'); here.

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
Contributor

Choose a reason for hiding this comment

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

Sure, but who would name this command0? 😄
It won't even work with the symfony baseApplication and will juste execute the default command.

Copy link
ContributorAuthor

@ro0NLro0NLJul 21, 2017
edited
Loading

Choose a reason for hiding this comment

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

Yeah.. to me that should benull !== $name as well :)

* @return string The value of the first argument or null otherwise
(or null otherwise)

If you insist i change it, just saying im preserving previous behavior :)

@fabpot
Copy link
Member

Thank you@ro0NL.

@fabpotfabpot closed thisJul 22, 2017
fabpot added a commit that referenced this pull requestJul 22, 2017
This PR was squashed before being merged into the 3.4 branch (closes#23519).Discussion----------[TwigBundle] Commands as a service| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->tiny step towards#23488Commits-------9839140 [TwigBundle] Commands as a service
@ro0NLro0NL deleted the twig/commands branchJuly 22, 2017 08:51
<services>
<defaultspublic="false" />

<serviceid="twig.command.debug"class="Symfony\Bridge\Twig\Command\DebugCommand">
Copy link
Contributor

Choose a reason for hiding this comment

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

are we not using class name == service id convention for new code?

nicolas-grekas added a commit that referenced this pull requestAug 30, 2017
This PR was merged into the 3.4 branch.Discussion----------[TwigBundle] require twig-bridge ~3.4| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Injecting "twig" as first arg of the DebugCommand works only in ^3.4 - as of#23519.Commits-------03816b7 [TwigBundle] require twig-bridge ~3.4
This was referencedOct 18, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

@fabpotfabpotfabpot approved these changes

@chalasrchalasrchalasr approved these changes

+2 more reviewers

@TobionTobionTobion left review comments

@ogizanagiogizanagiogizanagi approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

9 participants

@ro0NL@fabpot@dunglas@nicolas-grekas@Tobion@xabbuh@ogizanagi@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp