mayeco / easy-annotation-bundle
Easy annotation for Symfony2
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- sensio/framework-extra-bundle: 3.0.*@dev
This package is not auto-updated.
Last update: 2024-10-26 15:34:18 UTC
README
Prerequisites
SensioFrameworkExtraBundle
Example
A sample anotation that validate only ajax request.
<?php namespace Acme\AcmeBundle\Configuration; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation; use Mayeco\EasyAnnotationBundle\Configuration\ExecutableAnnotationControllerInterface; /** * @Annotation */ class OnlyAjax extends ConfigurationAnnotation implements ExecutableAnnotationControllerInterface { public function executeOnController(FilterControllerEvent $event) { if(!$event->getRequest()->isXmlHttpRequest()) { throw new AccessDeniedHttpException("No valid"); } } public function getAliasName() { return 'onlyajax'; } public function allowArray() { return false; } }
Use in your controller
... use Acme\AcmeBundle\Configuration\OnlyAjax; ... ... /** * * OnlyAjax() */ public function myAjaxFoo(Request $request) {