diff --git a/system/Application.php b/system/Application.php index c4304267..37431a7e 100644 --- a/system/Application.php +++ b/system/Application.php @@ -47,6 +47,22 @@ class Application extends BaseApplication } + /** + * @param $name + * @param $service + * @return Application + * @throws Exception + */ + public function import(string $name, string $service) + { + $class = $this->set($name, ['class' => $service]); + if (method_exists($class, 'onImport')) { + $class->onImport($this); + } + return $this; + } + + /** * @throws Exception */ diff --git a/system/Di/Service.php b/system/Di/Service.php index 06604cae..88ba5817 100644 --- a/system/Di/Service.php +++ b/system/Di/Service.php @@ -76,7 +76,6 @@ class Service extends Component if ($definition === NULL) { return $this->remove($id); } - unset($this->_components[$id]); if (is_object($definition) || is_callable($definition, TRUE)) { return $this->_definition[$id] = $definition;