Extra Module
Categories
Component ID
2123469
Component name
Extra Module
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Extra Module Add conventions to Twig engine and annotations to Drupal controllers, allowing to create more concise controllers and templates.
This modules is an implementation of http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle
Usage
- Download and enable module
- Use your awesome powers
@Permission Annotation
class DefaultController extends ControllerBase{
//...
/**
* helloAction
* @param string $name
*
* @Permission("access content")
*/
public function helloAction($name) {
return "Hello " . $name . "!";
}
//...
}
Call twig template like Symfony
{# hello.html.twig #}
{% extends "module_name::base.html.twig" %}
{% block hello_wrapper %}
Hellos {{name}}
{% endblock %}
// Controller
class DefaultController extends ControllerBase implements ContainerInjectionInterface {
//...
public function helloAction($name) {
$template = $this->twig->loadTemplate('module_name::hello.html.twig');
return $template->render(array(
'name' => $name
));
}
//...
}
Roadmap
- Template annotation
