Q:

Inject bundle into service in symfony 2

Is there a way to inject a bundle into a service?
I would like to write my service constructor like this:
<?php
use Symfony\Component\HttpKernel\Bundle\Bundle;

class MyService
{
    /** @var Bundle */
    private $bundle;

    public function __construct(Bundle $bundle) 
    {
        $this->bundle = $bundle;
    }
}

For the services.yml I'd like to have something like this:
services:
    my_service:
        class:     MyService
        arguments: ['how_can_i_reference_a_bundle']

A:

Your bundle can be setup as a service like that:
services:
    acme_foo_bundle:
        class: Acme\Foo\AcmeFooBundle
        factory_service: kernel
        factory_method: getBundle
        arguments:
            - "AcmeFooBundle"

