This bundle provides an easy way to create annotations for class, methods and properties of a controller.
Compatibility: Symfony 2.0+
Please follow the steps given here to install this bundle.
<?php
namespace MyProject\MyBundle\MyAnnotations;
use Symfony\Component\HttpKernel\KernelEvents;
use APY\EasyAnnotationBundle\Annotation\EasyAnnotation;
class MaxAge extends EasyAnnotation
{
public function process($annotationScope, $event, $class, $method)
{
if ($annotationScope != self::propertyScope) {
$response = $event->getResponse();
$response->setMaxAge($this->value);
$event->setResponse($response);
}
}
public function getEvent(){
return KernelEvents::RESPONSE;
}
}
<?php
// MyProject\MyBundle\DefaultController.php
namespace MyProject\MyBundle\Controller;
use MyProject\MyBundle\MyAnnotations\MaxAge;
/**
* General setting for all actions
* @MaxAge("15")
*/
class DefaultController
{
public function indexAction()
{
...
}
/**
* Specific setting only for this action
* @MaxAge("10")
*/
public function index2Action()
{
...
}
}
See full examples here.
The following documents are available:
- Installation
- How it works
- Annotation scope
- Annotation parameters
- Trigger Event