mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-30 22:48:19 +08:00
Added YiiBase::importNamespaces().
This commit is contained in:
@@ -138,6 +138,30 @@ class YiiBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imports a set of namespaces.
|
||||||
|
*
|
||||||
|
* By importing a namespace, the method will create an alias for the directory corresponding
|
||||||
|
* to the namespace. For example, if "foo\bar" is a namespace associated with the directory
|
||||||
|
* "path/to/foo/bar", then an alias "@foo/bar" will be created for this directory.
|
||||||
|
*
|
||||||
|
* This method is typically invoked in the bootstrap file to import the namespaces of
|
||||||
|
* the installed extensions. By default, Composer, when installing new extensions, will
|
||||||
|
* generate such a mapping file which can be loaded and passed to this method.
|
||||||
|
*
|
||||||
|
* @param array $namespaces the namespaces to be imported. The keys are the namespaces,
|
||||||
|
* and the values are the corresponding directories.
|
||||||
|
*/
|
||||||
|
public static function importNamespaces($namespaces)
|
||||||
|
{
|
||||||
|
foreach ($namespaces as $name => $path) {
|
||||||
|
if ($name !== '') {
|
||||||
|
$name = '@' . str_replace('\\', '/', $name);
|
||||||
|
static::setAlias($name, $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates a path alias into an actual path.
|
* Translates a path alias into an actual path.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,11 +56,6 @@ class Application extends Module
|
|||||||
* If this is false, layout will be disabled.
|
* If this is false, layout will be disabled.
|
||||||
*/
|
*/
|
||||||
public $layout = 'main';
|
public $layout = 'main';
|
||||||
/**
|
|
||||||
* @var array list of installed extensions. The array keys are the extension names, and the array
|
|
||||||
* values are the corresponding extension root source directories or path aliases.
|
|
||||||
*/
|
|
||||||
public $extensions = array();
|
|
||||||
|
|
||||||
private $_ended = false;
|
private $_ended = false;
|
||||||
|
|
||||||
@@ -92,13 +87,6 @@ class Application extends Module
|
|||||||
throw new InvalidConfigException('The "basePath" configuration is required.');
|
throw new InvalidConfigException('The "basePath" configuration is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['extensions'])) {
|
|
||||||
foreach ($config['extensions'] as $name => $path) {
|
|
||||||
Yii::setAlias("@$name", $path);
|
|
||||||
}
|
|
||||||
unset($config['extensions']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerErrorHandlers();
|
$this->registerErrorHandlers();
|
||||||
$this->registerCoreComponents();
|
$this->registerCoreComponents();
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class AssetBundle extends Object
|
|||||||
* @var array the options to be passed to [[AssetManager::publish()]] when the asset bundle
|
* @var array the options to be passed to [[AssetManager::publish()]] when the asset bundle
|
||||||
* is being published.
|
* is being published.
|
||||||
*/
|
*/
|
||||||
public $publishOption = array();
|
public $publishOptions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the bundle.
|
* Initializes the bundle.
|
||||||
@@ -119,7 +119,7 @@ class AssetBundle extends Object
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sourcePath !== null) {
|
if ($this->sourcePath !== null) {
|
||||||
list ($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOption);
|
list ($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->js as $js => $options) {
|
foreach ($this->js as $js => $options) {
|
||||||
|
|||||||
Reference in New Issue
Block a user