8000 [Twig] Decouple Twig commands from the Famework by GromNaN · Pull Request #9855 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Twig] Decouple Twig commands from the Famework #9855

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

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test, inline method and fix typo
  • Loading branch information
GromNaN committed Dec 30, 2013
commit a8fd92edf8b632e3ee4b7e220deb313ad1d98ac6
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
2.5.0
-----

* added command `twig:lint` from `TwigBundle`
* moved command `twig:lint` from `TwigBundle`

2.4.0
-----
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ private function createCommandTester()
{
$twig = new \Twig_Environment(new \Twig_Loader_Filesystem());

$command = new LintCommand();
$command->setTwigEnvironment($twig);

$application = new Application();
$application->add(new LintCommand($twig));
$application->add($command);
$command = $application->find('twig:lint');

return new CommandTester($command);
Expand Down
18 changes: 5 additions & 13 deletions src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ class LintCommand extends BaseLintCommand implements ContainerAwareInterface
*/
private $container;

/**
* @return ContainerInterface
*/
protected function getContainer()
{
if (null === $this->container) {
$this->container = $this->getApplication()->getKernel()->getContainer();
}

return $this->container;
}

/**
* {@inheritdoc}
*/
Expand All @@ -47,6 +35,10 @@ public function setContainer(ContainerInterface $container = null)
*/
public function getTwigEnvironment()
Copy link
Member

Choose a reason for hiding this comment

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

This should be protected like the one in the Bridge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

{
return $this->getContainer()->get('twig');
if (null === $this->container) {
$this->container = $this->getApplication()->getKernel()->getContainer();
Copy link
Member

Choose a reason for hiding this comment

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

Afaik, container can't be null,as it's set by setContainer during initialization?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exact, I took that portion of code from ContainerAwareCommand; but it looks like a legacy fallback.
I've removed it.

}

return $this->container->get('twig');
}
}
0