di\Container build()

build() protected method Creates an instance of the specified class. This method will resolve dependencies of the specified class, instantiate them, and inject them into the new instance of the specified class. protected object build ( $class, $params, $config )$class string The class name $params array Constructor parameters $config array Configurations to be applied to the new instance return object The newly created instance of the specified class throws yii\di\NotInstantiableE

di\Container $singleton

$singleton public write-only property Class name, interface name or alias name public $this setSingleton ( $class, $definition = [], array $params = [] )

di\Container $definitions

$definitions public read-only property The list of the object definitions or the loaded shared objects (type or ID => definition or instance). public array getDefinitions ( )

Dependency Injection Container

Dependency Injection Registering Dependencies Resolving Dependencies Practical Usage When to Register Dependencies Summary A dependency injection (DI) container is an object that knows how to instantiate and configure objects and all their dependent objects. Martin Fowler's article has well explained why DI container is useful. Here we will mainly explain the usage of the DI container provided by Yii. Dependency Injection Yii provides the DI container feature through the class yii\di\Contain

debug\TimelineAsset $sourcePath

$sourcePath public property public $sourcePath = '@yii/debug/assets'

debug\TimelineAsset $js

$js public property public $js = ['timeline.js']

debug\TimelineAsset $css

$css public property public $css = ['timeline.css']

debug\panels\TimelinePanel setColors()

setColors() public method Sets color indicators. key: percentages of time request, value: hex color public void setColors ( $colors )$colors array

debug\panels\TimelinePanel save()

save() public method Saves data to be later used in debugger detail view. This method is called on every page where debugger is enabled. public mixed save ( )return mixed Data to be saved

debug\panels\TimelinePanel load()

load() public method Loads data into the panel public void load ( $data )$data mixed