Skip to content

Instantly share code, notes, and snippets.

@piotrbelina
Last active December 26, 2015 04:49
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 piotrbelina/7096701 to your computer and use it in GitHub Desktop.
Save piotrbelina/7096701 to your computer and use it in GitHub Desktop.
<?php
class B {}
class A {
protected $b;
public function __construct()
{
$this->b = new B();
}
}
$a = new A();
?>
<?php
class B {}
class A
{
protected $b;
public function __construct(B $b)
{
$this->b = $b;
}
}
$b = new B();
$a = new A($b);
<parameters>
<parameter key="a.class">A</parameter>
<parameter key="b.class">B</parameter>
</parameters>
<services>
<service id="b" class="%b.class%">
</service>
<service id="a" class="%a.class%">
<argument type="service" id="b"/>
</service>
</services>
parameters:
a.class: A
b.class: B
services:
b:
class: %b.class%
a:
class: %a.class%
arguments: [@b]
<?php
$a = $container->get('a');
// $a = new A(new B());
<?php
class Baobaz_Training_Model_Profile_Catalog_Import_Simple extends BFlow_Core_Model_Flow_Profile
{
public function __construct(
BFlow_Core_Model_Flow_Action $validatorAction,
BFlow_Core_Model_Flow_Action $parserAction,
BFlow_Core_Model_Flow_Action $writerAction,
\Psr\Log\LoggerInterface $logger
) {
$this->validatorAction = $validatorAction;
$this->parserAction = $parserAction;
$this->writerAction = $writerAction;
$this->logger = $logger;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment