I have been learning phalcon and trying to use a base service with certain member variables and functions. I would like to extend it in multiple other services so that i don't have to redefine the arguments/calls during service registration of child classes. How can I achieve it? eg:
class BaseManager {
protected $logger;
protected $extService;
public function setLogger($logger){
$this->logger = $logger;
}
public function setExtService($extService) {
$this->extService = $extService;
}
}
For this I have defined service registration as
$di->set('baseManager', array(
'className' => 'Services\BaseManager',
'calls' => array(
array(
'method' => 'setLogger',
'arguments' => array(array('type' => 'service','name' => 'logger'))
),
array(
'method' => 'setExtService',
'arguments' => array(array('type' => 'service','name' => 'extService'))
)
)
)
);
Now I need to define another service extending the BaseManager
class CustomManager extends BaseManager{
....
...
}
How do I need to define the service registration of the new class CustomManager? I have tried simply using
$di->set('CustomManager', array(
'className' => 'Services\CustomManager'
)
);
But this does not instantiate the member variables of the base. I was using Symfony2 before and it had the option of specifying "parent". What can be done in phalcon to achieve similar functionality?