/** * 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); } }