protected function saveTargets($targets, $bundleFile)
    {
        $array = [];
        foreach ($targets as $name => $target) {
            if (isset($this->targets[$name])) {
                $array[$name] = array_merge($this->targets[$name], [
                    '__class' => get_class($target),
                    'sourcePath' => null,
                    'basePath' => $this->targets[$name]['basePath'],
                    'baseUrl' => $this->targets[$name]['baseUrl'],
                    'js' => $target->js,
                    'css' => $target->css,
                    'depends' => [],
                ]);
            } else {
                if ($this->isBundleExternal($target)) {
                    $array[$name] = $this->composeBundleConfig($target);
                } else {
                    $array[$name] = [
                        'sourcePath' => null,
                        'js' => [],
                        'css' => [],
                        'depends' => $target->depends,
                    ];
                }
            }
        }
        $array = VarDumper::export($array);
        $version = date('Y-m-d H:i:s');
        $bundleFileContent = <<<EOD
<?php
/**
 * This file is generated by the "yii {$this->id}" command.
 * DO NOT MODIFY THIS FILE DIRECTLY.
 * @version {$version}
 */
return {$array};
EOD;
        if (!file_put_contents($bundleFile, $bundleFileContent, LOCK_EX)) {
            throw new Exception("Unable to write output bundle configuration at '{$bundleFile}'.");
        }
        $this->stdout("Output bundle configuration created at '{$bundleFile}'.\n", Console::FG_GREEN);
    }
protected function saveTargets($targets, $bundleFile)
    {
        $array = [];
        foreach ($targets as $name => $target) {
            if (isset($this->targets[$name])) {
                $array[$name] = array_merge($this->targets[$name], [
                    '__class' => get_class($target),
                    'sourcePath' => null,
                    'basePath' => $this->targets[$name]['basePath'],
                    'baseUrl' => $this->targets[$name]['baseUrl'],
                    'js' => $target->js,
                    'css' => $target->css,
                    'depends' => [],
                ]);
            } else {
                if ($this->isBundleExternal($target)) {
                    $array[$name] = $this->composeBundleConfig($target);
                } else {
                    $array[$name] = [
                        'sourcePath' => null,
                        'js' => [],
                        'css' => [],
                        'depends' => $target->depends,
                    ];
                }
            }
        }
        $array = VarDumper::export($array);
        $version = date('Y-m-d H:i:s');
        $bundleFileContent = <<<EOD
<?php
/**
 * This file is generated by the "yii {$this->id}" command.
 * DO NOT MODIFY THIS FILE DIRECTLY.
 * @version {$version}
 */
return {$array};
EOD;
        if (!file_put_contents($bundleFile, $bundleFileContent, LOCK_EX)) {
            throw new Exception("Unable to write output bundle configuration at '{$bundleFile}'.");
        }
        $this->stdout("Output bundle configuration created at '{$bundleFile}'.\n", Console::FG_GREEN);
    }
protected function saveTargets ( $ targets , $ bundleFile ) { $ array = [ ] ; foreach ( $ targets as $ name => $ target ) { if ( isset ( $ this -> targets [ $ name ] ) ) { $ array [ $ name ] = array_merge ( $ this -> targets [ $ name ] , [ '__class' => get_class ( $ target ) , 'sourcePath' => null , 'basePath' => $ this -> targets [ $ name ] [ 'basePath' ] , 'baseUrl' => $ this -> targets [ $ name ] [ 'baseUrl' ] , 'js' => $ target -> js , 'css' => $ target -> css , 'depends' => [ ] , ] ) ; } else { if ( $ this -> isBundleExternal ( $ target ) ) { $ array [ $ name ] = $ this -> composeBundleConfig ( $ target ) ; } else { $ array [ $ name ] = [ 'sourcePath' => null , 'js' => [ ] , 'css' => [ ] , 'depends' => $ target -> depends , ] ; } } } $ array = VarDumper :: export ( $ array ) ; $ version = date ( 'Y-m-d H:i:s' ) ; $ bundleFileContent =  <<<EOD
<?php
/**
 * This file is generated by the "yii {$this->id}" command.
 * DO NOT MODIFY THIS FILE DIRECTLY.
 * @version {$version}
 */
return {$array};
EOD ; if ( ! file_put_contents ( $ bundleFile , $ bundleFileContent , LOCK_EX ) ) { throw new Exception ( "Unable to write output bundle configuration at '{$bundleFile}'." ) ; } $ this -> stdout ( "Output bundle configuration created at '{$bundleFile}'.\n" , Console :: FG_GREEN ) ; }
Saves new asset bundles configuration.
@param \yii\web\AssetBundle[] $targets list of asset bundles to be saved.
@param string $bundleFile output file name.
@throws Exception on failure.
Saves new asset bundles configuration .