yii\di\Instance::get PHP Method

get() public method

Returns the actual object referenced by this Instance object.
public get ( ServiceLocator | Container $container = null ) : object
$container ServiceLocator | 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 (Yii::$app && Yii::$app->has($this->id)) {
            return Yii::$app->get($this->id);
        } else {
            return Yii::$container->get($this->id);
        }
    }