Created
July 23, 2015 08:39
-
-
Save settermjd/33566c7c446d758203b0 to your computer and use it in GitHub Desktop.
zend di example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace DiExample; | |
class DummyDateCalculator | |
{ | |
protected $date; | |
protected $secondDate; | |
public function __construct(\DateTime $date) | |
{ | |
$this->date = $date; | |
} | |
public function setSecondDate(\DateTime $secondDate) | |
{ | |
$this->secondDate = $secondDate; | |
} | |
public function __toString() | |
{ | |
return "Time was initialised at: " . $this->date->format(\DateTime::ATOM); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$di->configure(new Zend\Di\Config([ | |
'definition' => [ | |
'instance' => [ | |
'DiExample\DummyDateCalculator' => [ | |
'parameters' => [ | |
'parameter' => [ | |
'date' => [ | |
'type' => '\DateTime', | |
'required' => true | |
] | |
] | |
] | |
] | |
] | |
] | |
])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment