idea-php-drupal-symfony2-bridge icon indicating copy to clipboard operation
idea-php-drupal-symfony2-bridge copied to clipboard

Can we add parsing for hook_theme

Open jibran opened this issue 10 years ago • 2 comments

First of all thank you for making this plugin. In drupal 8 hook_theme are defined like this.

/**
 * Implements hook_theme().
 */
function user_theme() {
  return array(
    'user' => array(
      'render element' => 'elements',
    ),
    'username' => array(
      'variables' => array('account' => NULL, 'attributes' => array(), 'link_options' => array()),
    ),
  );
}

It means there are user.twig.html and username.twig.html in the core. Can we add the functionality to go to user.twig.html or username.twig.html form the above theme function? A small t for template sign next to the 'username' and 'user' string just like routes or services would take us to respective templates.

ThemeRegistryLoader::findTemplate() is the function which coverts these strings to template file

jibran avatar Jun 23 '15 04:06 jibran

If you want to have a look at complete processing of the hook the code is in Registry::processExtension.

jibran avatar Jun 23 '15 04:06 jibran

basically twig path resolve will provide massive more functionality of the symfony2 plugin. also piping variables are possible here. need to implement an extension point first.

you are welcome to provide more examples of how i can parse templates and their vars :).

Haehnchen avatar Jul 12 '15 13:07 Haehnchen