2017 © Pedro Peláez
 

symfony-bundle magic-injection-bundle

Magically inject dependencies into services

image

ppokatilo/magic-injection-bundle

Magically inject dependencies into services

  • Thursday, December 4, 2014
  • by SHyx0rmZ
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

magic-injection-bundle

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This Symfony2 bundle provides a way to magically inject dependencies into your services. The dependencies will not be available in the constructor. To use it, you need to complete the following steps:, (*2)

  1. Add the tag magic_injection.injectable_service to the service you wish to inject. The tag takes an optional argument called type, which you can use to group injectable services.
  2. Add the tag magic_injection.injection_target to the service which should receive the injected services.
  3. Finally, annotate properties with the MagicInjection annotation, which will take an optional type argument that refers to a group of injectable services.

Example usage

  • services.yml, (*3)

    services:
    
    service.that.will.be.injected:
      class: Service\MyServiceA
      tags:
        - { name: magic_injection.injectable_service, type: my_services }
    
    service.that.has.a.dependency:
      class: Service\MyServiceB
      tags:
        - { name: magic_injection.injection_target }
    
  • MyServiceB.php, (*4)

    class MyServiceB
    {
    /**
     * @MagicInjection(type="my_services")
     * @var \Service\MyServiceA
     */
    private $myServiceA;
    
    public function __construct()
    {
      assert($this->myServiceA === null);
    }
    
    public function foo()
    {
      $this->myServiceA->bar();
    }
    }
    

The Versions

04/12 2014

dev-master

9999999-dev http://github.com/SHyx0rmZ/magic-injection-bundle

Magically inject dependencies into services

  Sources   Download

MIT

The Requires

 

by Patrick Pokatilo

service bundle symfony magic injection

15/11 2014

v1.0.3

1.0.3.0 http://github.com/SHyx0rmZ/magic-injection-bundle

Magically inject dependencies into services

  Sources   Download

MIT

The Requires

 

by Patrick Pokatilo

service bundle symfony magic injection

15/11 2014

v1.0.2

1.0.2.0 http://github.com/SHyx0rmZ/magic-injection-bundle

Magically inject dependencies into services

  Sources   Download

MIT

The Requires

 

by Patrick Pokatilo

service bundle symfony magic injection

15/11 2014

v1.0.1

1.0.1.0 http://github.com/SHyx0rmZ/magic-injection-bundle

Magically inject dependencies into services

  Sources   Download

MIT

The Requires

 

by Patrick Pokatilo

service bundle symfony magic injection

15/11 2014

v1.0.0

1.0.0.0 http://github.com/SHyx0rmZ/magic-injection-bundle

Magically inject dependencies into services

  Sources   Download

MIT

The Requires

 

by Patrick Pokatilo

service bundle symfony magic injection