Yii2 DI容器类实例引用
2019-08-25 22:21:19 10 举报
AI智能生成
Yii2 DI容器类实例引用
作者其他创作
大纲/内容
yii\\di\\Instance
public $id;
protected __construct($id)
$this->id = $id;
static::of($id)
return new static($id);
if (is_array($reference))
$class = isset($reference['class']) ? $reference['class'] : $type;
if (!$container instanceof Container)
container = Yii::$container;
if (is_string($reference))
$reference = new static($reference);
elseif ($type === null || $reference instanceof $type)
return $reference;
if ($reference instanceof self)
$component = $reference->get($container);
if ($type === null || $component instanceof $type)
return $component;
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);
0 条评论
回复 删除
下一页