PHP Classes

File: vendor/symfony/dependency-injection/Tests/Fixtures/containers/container19.php

Recommend this page to a friend!
  Classes of Gavin Gordon Markowski  >  Helphp PHP Class Generator  >  vendor/symfony/dependency-injection/Tests/Fixtures/containers/container19.php  >  Download  
File: vendor/symfony/dependency-injection/Tests/Fixtures/containers/container19.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Helphp PHP Class Generator
Generate classes from configuration parameters
Author: By
Last change:
Date: 6 months ago
Size: 665 bytes
 

Contents

Class file image Download
<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;
use
Symfony\Component\DependencyInjection\Definition;

require_once
__DIR__.'/../includes/classes.php';

$container = new ContainerBuilder();

$container
   
->register('service_from_anonymous_factory', 'Bar\FooClass')
    ->
setFactory(array(new Definition('Bar\FooClass'), 'getInstance'))
;

$anonymousServiceWithFactory = new Definition('Bar\FooClass');
$anonymousServiceWithFactory->setFactory('Bar\FooClass::getInstance');
$container
   
->register('service_with_method_call_and_factory', 'Bar\FooClass')
    ->
addMethodCall('setBar', array($anonymousServiceWithFactory))
;

return
$container;