Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created September 1, 2013 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakura10/6406265 to your computer and use it in GitHub Desktop.
Save bakura10/6406265 to your computer and use it in GitHub Desktop.
<?php
class CompiledFactory2 implements FactoryInterface
{
public function createService(ServiceLocatorInterface $sl)
{
$a = new A();
$b = $sl->get('A');
return new B(a);
}
}
<?php
class Factory1 implements FactoryInterface
{
public function createService(ServiceLocatorInterface $sl)
{
$a = new A();
return $a;
}
}
<?php
class Factory2 implements FactoryInterface
{
public function createService(ServiceLocatorInterface $sl)
{
$b = $sl->get('A');
return new B(a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment