Controller Annotations
Categories
Component ID
2893834
Component name
Controller Annotations
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Downloads
109
Component created
Component changed
Component body
A Drupal port of the controller annotations from Symfony Framework which makes it a lot easier to create custom controllers based on annotations.
Quick example on what you can do with it:
namespace DrupalacmeController;
use Drupalcontroller_annotationsConfigurationRoute;
use Drupalcontroller_annotationsConfigurationCache;
use Drupalcontroller_annotationsConfigurationTemplate;
use Drupalcontroller_annotationsConfigurationParamConverter;
use Drupalcontroller_annotationsConfigurationMethod;
use Drupalcontroller_annotationsConfigurationSecurity;
use Drupalcontroller_annotationsConfigurationTitle;
use Drupal
odeEntityNode;
/**
* @Route("/articles")
* @Cache(expires="tomorrow")
*/
class ArticleController
{
/**
* @Route
* @Template
* @Security(permission="access content")
* @Title("My Title")
*/
public function indexAction()
{
$articles = ...;
return ['articles' => $articles];
}
/**
* @Route("/{id}", name="article_edit")
* @Method("GET")
* @ParamConverter("article", options={"bundle": "article"})
* @Template("acme:article:edit", vars={"article"})
* @Cache(smaxage="15")
* @Security(role="administrator")
*/
public function editAction(Node $article) { }
}
Install with composer require drupal/controller_annotations and enable from your admin panel or use drush: drush en controller_annotations -y.
View the full documentation on the Github page.
