<?php
/**
* cvServiceSubcontainer
*
* Abstract class subcontainers
*
* @package CYBERVILLE
* @subpackage DI
* @author Kochergin Nick <[email protected]>, <http://cyberville-project.ru>
* @version $Id$
*/
abstract class cvServiceSubcontainer {
protected $basic_container = null;
/**
* Set of the basic container
*
* @param cvServiceContainer $container
*/
public function setBasicContainer(cvServiceContainer $container) {
$this->basic_container = $container;
}
/**
* Returns true if the given service is defined.
*
* @param string $id The service identifier
*
* @return Boolean true if the container has a service with the given identifier, false otherwise
*/
public function __isset($id) {
return $this->basic_container->hasService($id, get_called_class());
}
/**
* Gets the service associated with the given identifier.
*
* @param string $id The service identifier
*
* @return mixed The service instance associated with the given identifier
*/
public function __get($id) {
return $this->basic_container->getService($id, get_called_class());
}
/**
* Sets a service.
*
* @param string $id The service identifier
* @param mixed $service A service instance
*/
public function __set($id, $service) {
$this->basic_container->setService($id, $service);
}
/**
* Removes a service by identifier.
*
* @param string $id The service identifier
*/
public function __unset($id) {
throw new LogicException('You can\'t unset a service.');
}
}
?>