Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created July 23, 2015 08:39
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 settermjd/33566c7c446d758203b0 to your computer and use it in GitHub Desktop.
Save settermjd/33566c7c446d758203b0 to your computer and use it in GitHub Desktop.
zend di example
<?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);
}
}
$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