8000 Use the router to resolve the file links in the profiler by javiereguiluz · Pull Request #24153 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Use the router to resolve the file links in the profiler #24153

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

Conversation

javiereguiluz
Copy link
Member
Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #22290
License MIT
Doc PR -


public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
public function __construct($fileLinkFormat = null, RouterInterface $router = null, $baseDir = null, $queryString = null)
Copy link
Member

Choose a reason for hiding this comment

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

the typehint should be UrlGeneratorInterface, as yo only want to generate (Silex does not have a service implementing RouterInterface for instance, as it has 2 services for the matcher and the generator)


public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
public function __construct($fileLinkFormat = null, RouterInterface $router = null, $baseDir = null, $queryString = null)
Copy link
Member

Choose a reason for hiding this comment

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

Changing the signature is a BC break (it might break SilexWebProfiler btw)

Copy link
Member Author

Choose a reason for hiding this comment

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

If I'm right, we don't care about BC breaks in debug tools like this one.


$this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3));
return new Router(new ClosureLoader(), $routeCollection);
Copy link
Member

Choose a reason for hiding this comment

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

you could use return new UrlGenerator($routecollection, new RequestContext()) (with $routeCollection being the RouteCollection itself rather than a closure returning it)


public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
public function __construct($fileLinkFormat = null, UrlGeneratorInterface $router = null, $baseDir = null, $queryString = null)
Copy link
Member

Choose a reason for hiding this comment

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

The type change is a BC break. I saw the comment saying we don't care because this is debug tool, but I don't think we've done any such BC break before (we did some for the profiler, but they were behavior ones, not "interface" ones AFAIK.)

);
}

if (null === $this->router) {
Copy link
Member

Choose a reason for hiding this comment

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

If router is null, then we probably need to fallback using the request stack for BC compat.

{
// TODO: '$requestStack' constructor argument is unused. Remove it in Symfony 4.0.
Copy link
Member

Choose a reason for hiding this comment

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

We won't be able to do that. What would be better is to remove the type hint for $requestStack, accept both a RequestStack and a UrlGeneratorInterface, trigger a deprecation if this is a RequestStack. That way, we can remove the deprecated part in 4.0.

@fabpot
Copy link
Member
fabpot commented Oct 1, 2017

@javiereguiluz Can you finish this one by taking account comments? Thanks.


public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $queryString = null, UrlGeneratorInterface $router = null)
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 doing what I suggested instead. Keeping the second argument, deprecating the fact that you can pass a RequestStack as a second argument, and accept a UrlGenerator as well? That way, we can remove the possibility to pass a RequestStack in 4.0, which is cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

nvm, I've implemented my suggestion in f659954

@javiereguiluz
Copy link
Member Author

With the latest changes made by Fabien, this should be ready for the final review.


if (null !== $this->urlGenerator) {
return array(
$this->urlGenerator->generate('_profiler_open_file').$this->queryString,
Copy link
Member

Choose a reason for hiding this comment

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

That ties it to the definition of WebProfilerBundle. I suggest that we make it configurable instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could we please do that in the future in case enough people ask for it?


public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
/**
* @param $urlGenerator UrlGeneratorInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

@param UrlGeneratorInterface $urlGenerator

@xabbuh xabbuh modified the milestones: 3.3, 3.4 Jan 29, 2018
@xabbuh
Copy link
Member
xabbuh commented Jan 29, 2018

moving to the 3.4 milestone as the last bugfix release for 3.3 was published today

@nicolas-grekas
Copy link
Member
nicolas-grekas commented Mar 21, 2018

This looks overkill for the purpose. Instead, I would suggest to just make this hardcoded URL a parameter. And maybe populate this parameter automatically in a late compiler pass.

@nicolas-grekas
Copy link
Member

Hum, in fact here is an approach that works: #22290
Closing here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0