framework/web/View.php
public function registerAssetBundle($name, $position = null)
    {
        if (!isset($this->assetBundles[$name])) {
            $am = $this->getAssetManager();
            $bundle = $am->getBundle($name);
            $this->assetBundles[$name] = false;
            // register dependencies
            $pos = isset($bundle->jsOptions['position']) ? $bundle->jsOptions['position'] : null;
            foreach ($bundle->depends as $dep) {
                $this->registerAssetBundle($dep, $pos);
            }
            $this->assetBundles[$name] = $bundle;
        } elseif ($this->assetBundles[$name] === false) {
            throw new InvalidConfigException("A circular dependency is detected for bundle '$name'.");
        } else {
            $bundle = $this->assetBundles[$name];
        }

        if ($position !== null) {
            $pos = isset($bundle->jsOptions['position']) ? $bundle->jsOptions['position'] : null;
            if ($pos === null) {
                $bundle->jsOptions['position'] = $pos = $position;
            } elseif ($pos > $position) {
                throw new InvalidConfigException("An asset bundle that depends on '$name' has a higher javascript file position configured than '$name'.");
            }
            // update position for all dependencies
            foreach ($bundle->depends as $dep) {
                $this->registerAssetBundle($dep, $pos);
            }
        }

        return $bundle;
    }
public function registerAssetBundle($name, $position = null)
    {
        if (!isset($this->assetBundles[$name])) {
            $am = $this->getAssetManager();
            $bundle = $am->getBundle($name);
            $this->assetBundles[$name] = false;
            // register dependencies
            $pos = isset($bundle->jsOptions['position']) ? $bundle->jsOptions['position'] : null;
            foreach ($bundle->depends as $dep) {
                $this->registerAssetBundle($dep, $pos);
            }
            $this->assetBundles[$name] = $bundle;
        } elseif ($this->assetBundles[$name] === false) {
            throw new InvalidConfigException("A circular dependency is detected for bundle '$name'.");
        } else {
            $bundle = $this->assetBundles[$name];
        }

        if ($position !== null) {
            $pos = isset($bundle->jsOptions['position']) ? $bundle->jsOptions['position'] : null;
            if ($pos === null) {
                $bundle->jsOptions['position'] = $pos = $position;
            } elseif ($pos > $position) {
                throw new InvalidConfigException("An asset bundle that depends on '$name' has a higher javascript file position configured than '$name'.");
            }
            // update position for all dependencies
            foreach ($bundle->depends as $dep) {
                $this->registerAssetBundle($dep, $pos);
            }
        }

        return $bundle;
    }
public function registerAssetBundle ( $ name , $ position = null ) { if ( ! isset ( $ this -> assetBundles [ $ name ] ) ) { $ am = $ this -> getAssetManager ( ) ; $ bundle = $ am -> getBundle ( $ name ) ; $ this -> assetBundles [ $ name ] = false ; // register dependencies $ pos = isset ( $ bundle -> jsOptions [ 'position' ] ) ? $ bundle -> jsOptions [ 'position' ] : null ; foreach ( $ bundle -> depends as $ dep ) { $ this -> registerAssetBundle ( $ dep , $ pos ) ; } $ this -> assetBundles [ $ name ] = $ bundle ; } elseif ( $ this -> assetBundles [ $ name ] === false ) { throw new InvalidConfigException ( "A circular dependency is detected for bundle '$name'." ) ; } else { $ bundle = $ this -> assetBundles [ $ name ] ; } if ( $ position !== null ) { $ pos = isset ( $ bundle -> jsOptions [ 'position' ] ) ? $ bundle -> jsOptions [ 'position' ] : null ; if ( $ pos === null ) { $ bundle -> jsOptions [ 'position' ] = $ pos = $ position ; } elseif ( $ pos > $ position ) { throw new InvalidConfigException ( "An asset bundle that depends on '$name' has a higher javascript file position configured than '$name'." ) ; } // update position for all dependencies foreach ( $ bundle -> depends as $ dep ) { $ this -> registerAssetBundle ( $ dep , $ pos ) ; } } return $ bundle ; }
Registers the named asset bundle.
All dependent asset bundles will be registered.
@param string $name the class name of the asset bundle (without the leading backslash)
@param int|null $position if set, this forces a minimum position for javascript files.
This will adjust depending assets javascript file position or fail if requirement can not be met.
If this is null, asset bundles position settings will not be changed.
See [[registerJsFile]] for more details on javascript position.
@return AssetBundle the registered asset bundle instance
@throws InvalidConfigException if the asset bundle does not exist or a circular dependency is detected
Registers the named asset bundle . All dependent asset bundles will be registered .