Skip to content

[TwigBridge] Fix BC break due required twig environment #24851

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 2 commits into from
Closed
Changes from all commits
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
6 changes: 5 additions & 1 deletion src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
private $twig;
private $computed;

public function __construct(Profile $profile, Environment $twig)
public function __construct(Profile $profile, Environment $twig = null)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe passing null should trigger a deprecation warning, so we can remove the boilerplate below on the 4.0 branch again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds reasonable :) lets see what others think.

Copy link
Member

Choose a reason for hiding this comment

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

No need to "deprecate" that as we are talking about an additional feature.

{
$this->profile = $profile;
$this->twig = $twig;
Expand Down Expand Up @@ -62,6 +62,10 @@ public function lateCollect()
$this->data['profile'] = serialize($this->profile);
$this->data['template_paths'] = array();

if (null === $this->twig) {
return;
}

$templateFinder = function (Profile $profile) use (&$templateFinder) {
if ($profile->isTemplate()) {
try {
Expand Down