2017 © Pedro Peláez
 

symfony-bundle easy-annotation-bundle

Easy annotation for Symfony2

image

mayeco/easy-annotation-bundle

Easy annotation for Symfony2

  • Monday, November 3, 2014
  • by mayeco
  • Repository
  • 1 Watchers
  • 2 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EasyAnnotationBundle

Prerequisites

SensioFrameworkExtraBundle, (*1)

Example

A sample anotation that validate only ajax request., (*2)

<?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, (*3)

...
use Acme\AcmeBundle\Configuration\OnlyAjax;
...

...
    /**
     *
     * OnlyAjax()
     */
    public function myAjaxFoo(Request $request)
    {

The Versions

03/11 2014

dev-master

9999999-dev https://github.com/mayeco/EasyAnnotationBundle

Easy annotation for Symfony2

  Sources   Download

MIT

The Requires

 

by Mario Young

annotation