I'm using PhpStorm. I want to use the method name from the PHP class in the Live Template variable. But I didn't find the function for it on the page PhpStorm live template variables.
Is there a way to insert the method name into the template?
/**
* @return Response
* @Route(path="/profile", name="profile")
*/
public function profile(): Response
{
return $this->render("app/profile/$HOW_TO_INSERT_METHOD_NAME_HERE$.html.twig");
}
CodePudding user response:
This is not symfony specific but you can use the __METHOD__
constant. This will also include the class name though. Use __FUNCTION__
to only get the name of the method itself.
See this comment in the docs.
So like this:
return $this->render("app/profile/" . __FUNCTION__ . ".html.twig");
Demo: https://3v4l.org/mu5qB
CodePudding user response:
This isn't available for PHP, unfortunately. Here's a link to a corresponding feature request: https://youtrack.jetbrains.com/issue/WI-43488. Feel free to vote for or comment it in order to get notified about its updates.