idea-php-symfony2-plugin icon indicating copy to clipboard operation
idea-php-symfony2-plugin copied to clipboard

Is there a way to add PHP template name support for custom render function?

Open Anubarak opened this issue 4 years ago • 3 comments

Sorry for the incredible bad title.. and thank you very much for your great plugin, it really helps me. One thing I was looking for is the following:

My Controller

// works...
public function myFunction()
{
    $this->view->render('template-path.twig, ['var1' => 1]);
}

pressing CTRL enables me to jump right to the template and all variables in the template are available in PHPStorm image image

I would like to create a custom wrapper for this

public function myCustomTemplateRenderFunction(string $templateName, array $variables = [])
{
    // do some stuff, proceed the templateName and variables... custom logic here...

    return $this->view->render('calculations/' . $templateName . '.twig', $variables);
}

// .....
// automatically jumping to the template or variable suggestions is not possible here anymore
$this->myCustomTemplateRenderFunction('test', ['var1' => 1]);

So my question is: is there any possible way (via PHPDoc, Plugin Settings injection or whatever) to tell PHPStorm myCustomTemplateRenderFunction actually calls a render function with a certain path in the end?

Thank you very much.

Anubarak avatar Sep 13 '21 07:09 Anubarak

Maybe this is what you are looking for?

https://www.jetbrains.com/help/phpstorm/symfony-creating-helper-functions.html

Lorenzschaef avatar Nov 08 '21 10:11 Lorenzschaef

@Lorenzschaef Not 100% what I wanted - but I can go with that. Thank you very much. This functionality is awesome

Anubarak avatar Nov 08 '21 13:11 Anubarak

yes, in general i am thinking to support "wildcards" for templates in many places and also to improve all php completion with code path analyse, with both this would catch your use case here.

Haehnchen avatar May 04 '22 18:05 Haehnchen