Skip to content

Instantly share code, notes, and snippets.

@phalcon
Last active December 18, 2015 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phalcon/5695689 to your computer and use it in GitHub Desktop.
Save phalcon/5695689 to your computer and use it in GitHub Desktop.
<?php
class Data
{
protected $service;
public function setMyService($service)
{
$this->service = $service;
}
}
class myService
{
}
$di = new Phalcon\DI();
$di->set('myservice', function() {
return $myservice = new myService();
});
$di->set('Data', array(
'className' => 'Data',
'calls' => array(
array(
'method' => 'setMyservice',
'arguments' => array(
array('type' => 'service', 'name' => 'myservice'),
)
),
)
));
$data = $di->get('Data');
var_dump($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment