2017 © Pedro Peláez
 

symfony-bundle init-controller-bundle

Symple Initializable Controller

image

symple-dev/init-controller-bundle

Symple Initializable Controller

  • Thursday, February 18, 2016
  • by symple-dev
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Symple Initializable Controller

The Symple Initializable Controller Bundle permits initialization of Symfony controllers before invocation of action methods., (*1)

Content:, (*2)

, (*3)

Requirements

, (*4)

Installation

The suggested installation method is via composer:, (*5)

``` sh php composer.phar require symple-dev/init-controller-bundle:1.0.*, (*6)


<a name="config"></a> ## Configuration You can enable or disable **Symple Initializable Controller** in app/config.yml (default enabled): ``` yaml init_controller: enabled: true

, (*7)

Usage

, (*8)

Initializable Controller Interface

Implement the interface Symple\Bundle\InitControllerBundle\Controller\InitControllerInterface in your Controller., (*9)

``` php <?php namespace Controller;, (*10)

use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symple\Bundle\InitControllerBundle\Controller\InitControllerInterface;, (*11)

class MyController extends Controller implements InitControllerInterface { // ... }, (*12)

<a name="usage-annotation"></a>
### Init Annotation

The annotation **@Symple\Bundle\InitControllerBundle\Annotation\Init** tells that this method should be invoked before some action method (on _kernel.controller_ event).

Available configuration options:

- **priority** - integer value for invocation ordering (the greatest will be first), default 0
- **args** - array of method arguments (optional)

**Note:** that **@Init** annotation can be applied to public methods only.

``` php
<?php
namespace Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symple\Bundle\InitControllerBundle\Annotation\Init;
use Symple\Bundle\InitControllerBundle\Controller\InitControllerInterface;

class MyController extends Controller implements InitControllerInterface
{
    /**
     * @Init(priority = 200)
     */
    public function initialize1()
    {
        // do something
    }

    /**
     * @Init(priority = 100, args = {123, true})
     */
    public function initialize2($int, $bool = false)
    {
        // do something
    }

    public function indexAction()
    {
        // ...
    }
}

In this example following methods will be invoked before indexAction (or another action method):, (*13)

  1. initialize1();
  2. initialize2(123, true);

You can apply multiple @Init annotations to the same method., (*14)

The Versions

18/02 2016

dev-master

9999999-dev http://symple-dev.ru

Symple Initializable Controller

  Sources   Download

MIT

The Requires

 

by Constantine Seleznyoff

symfony controller symple initializable

18/02 2016

v1.0.1

1.0.1.0 http://symple-dev.ru

Symple Initializable Controller

  Sources   Download

MIT

The Requires

 

by Constantine Seleznyoff

symfony controller symple initializable

17/02 2016

v1.0.0

1.0.0.0 http://symple-dev.ru

Symfony Initializable Controllers

  Sources   Download

MIT

The Requires

 

by Constantine Seleznyoff

symfony controller symple initializable