2017 © Pedro Peláez
 

symfony-bundle controller-callback-bundle

A Symfony 2 bundle to add controller pre/post calls via route configuration

image

chrisjohnson00/controller-callback-bundle

A Symfony 2 bundle to add controller pre/post calls via route configuration

  • Sunday, September 14, 2014
  • by chrisjohnson00
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ControllerCallbackBundle

A Symfony 2 bundle which adds the ability to configure a controller function call before or after the action is called, (*1)

Continuous Integration

Build Status Scrutinizer Code Quality Code Coverage, (*2)

Installation

Installation by Composer

Add ControllerCallbackBundle bundle as a dependency to the composer.json of your application, (*3)

"require": {
    ...
    "chrisjohnson00/controller-callback-bundle": "dev-master"
    ...
},

Or on the command line with composer require chrisjohnson00/controller-callback-bundle, (*4)

Add ControllerCallbackBundle to your application kernel.

// app/AppKernel.php
<?php
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new ChrisJohnson00\ControllerCallbackBundle\ChrisJohnson00ControllerCallbackBundle(),
        );
    }

Example Usage

    <route id="quest_read" pattern="/api/quest/{id}" methods="GET">
        <default key="repository">FTWGuildBundle:Quest</default>
        <default key="type">read</default>
        <default key="_controller">FTWGuildBundle:Api:index</default>
        <default key="preActionMethod">setRouteParameters</default>
    </route>

The above will result in calling the Api controller method named setRouteParameters by passing in an associative array of all keys (including the id in the uri), (*5)

The setRouteParameters method may look something like, (*6)

    public function setRouteParameters(array $parameters)
    {
        $this->setRepository($parameters['repository']);
        $this->setType($parameters['type']);
        if (isset($parameters['id']))
            $this->setId($parameters['id']);
    }

The Versions

14/09 2014

dev-master

9999999-dev

A Symfony 2 bundle to add controller pre/post calls via route configuration

  Sources   Download

MIT

The Requires