astina/injection-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Lets you inject services and container parameters into controllers.

Installs: 6 043

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 12

Forks: 0

Type:symfony-bundle

0.2.0 2013-05-11 09:51 UTC

This package is not auto-updated.

Last update: 2022-06-20 03:21:09 UTC


README

Lets you inject services and container parameters into controllers.

Installation

Step 1: Add to composer.json

"require" :  {
    // ...
    "astina/injection-bundle":"dev-master",
}

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Astina\Bundle\InjectionBundle\AstinaInjectionBundle(),
    );
}

##Usage

use Astina\Bundle\InjectionBundle\Annotation as Inject;

class DefaultController
{
    /**
     * @Inject\Service("session")
     * @var SessionInterface
     */
    private $session;

    /**
     * @Inject\Parameter("acme_foo")
     */
    private $foo;

    /**
     * @Route("/foo", name="foo")
     * @Template
     */
    public function indexAction()
    {
        $foo = $this->session->get($this->foo);

        return array(
            'foo' => $foo,
        );
    }
}