コード例 #1
0
ファイル: Application.php プロジェクト: kerisy/framework
 public function init()
 {
     if (!defined('APPLICATION_PATH') || !file_exists(APPLICATION_PATH)) {
         throw new InvalidParamException("The param: 'APPLICATION_PATH' is invalid");
     }
     $this->components = array_merge($this->defaultComponents(), $this->config('components')->all());
     Container::getInstance()->setApp($this);
 }
コード例 #2
0
ファイル: functions.php プロジェクト: silov/framework
function service($service)
{
    return Container::getInstance()->getApp()->get($service);
}
コード例 #3
0
ファイル: Instance.php プロジェクト: hanfengyang/framework
 /**
  * Returns the actual object referenced by this Instance object.
  * @param ServiceLocator|Container $container the container used to locate the referenced object.
  * If null, the method will first try `Yii::$app` then `Yii::$container`.
  * @return object the actual object referenced by this Instance object.
  */
 public function get($container = null)
 {
     if ($container) {
         return $container->get($this->id);
     }
     if (app() && app()->has($this->id)) {
         return app()->get($this->id);
     } else {
         return Container::getInstance()->get($this->id);
     }
 }
コード例 #4
0
 /**
  * Get a service by it's id.
  *
  * @param $id
  * @return mixed
  */
 public function get($id)
 {
     return Container::getInstance()->get($id);
 }