Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
409c508f
Commit
409c508f
authored
Mar 31, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
7a234327
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
233 additions
and
314 deletions
+233
-314
Dictionary.php
framework/base/Dictionary.php
+12
-39
Module.php
framework/base/Module.php
+148
-243
Vector.php
framework/base/Vector.php
+3
-3
Exception.php
framework/db/Exception.php
+0
-1
BaseQuery.php
framework/db/dao/BaseQuery.php
+0
-1
ColumnSchema.php
framework/db/dao/ColumnSchema.php
+0
-1
Command.php
framework/db/dao/Command.php
+0
-1
Connection.php
framework/db/dao/Connection.php
+0
-1
DataReader.php
framework/db/dao/DataReader.php
+0
-1
Driver.php
framework/db/dao/Driver.php
+0
-1
Expression.php
framework/db/dao/Expression.php
+0
-1
Query.php
framework/db/dao/Query.php
+0
-1
QueryBuilder.php
framework/db/dao/QueryBuilder.php
+1
-2
TableSchema.php
framework/db/dao/TableSchema.php
+0
-1
Transaction.php
framework/db/dao/Transaction.php
+0
-1
Driver.php
framework/db/dao/mysql/Driver.php
+0
-1
QueryBuilder.php
framework/db/dao/mysql/QueryBuilder.php
+0
-1
Driver.php
framework/db/dao/sqlite/Driver.php
+0
-1
QueryBuilder.php
framework/db/dao/sqlite/QueryBuilder.php
+0
-1
DbTarget.php
framework/logging/DbTarget.php
+0
-1
EmailTarget.php
framework/logging/EmailTarget.php
+0
-1
FileTarget.php
framework/logging/FileTarget.php
+0
-1
Logger.php
framework/logging/Logger.php
+0
-1
ProfileTarget.php
framework/logging/ProfileTarget.php
+0
-1
Router.php
framework/logging/Router.php
+0
-1
Target.php
framework/logging/Target.php
+0
-1
WebTarget.php
framework/logging/WebTarget.php
+0
-1
ArrayHelper.php
framework/util/ArrayHelper.php
+67
-0
File.php
framework/util/File.php
+2
-2
Text.php
framework/util/Text.php
+0
-2
No files found.
framework/base/Dictionary.php
View file @
409c508f
...
...
@@ -9,6 +9,8 @@
namespace
yii\base
;
use
yii\util\ArrayHelper
;
/**
* Dictionary implements a collection that stores key-value pairs.
*
...
...
@@ -203,17 +205,15 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
*
* Existing elements in the dictionary will be overwritten if their keys are the same as those in the source.
* If the merge is recursive, the following algorithm is performed:
* <ul>
* <li>the dictionary data is saved as $a, and the source data is saved as $b;</li>
* <li>if $a and $b both have an array indxed at the same string key, the arrays will be merged using this algorithm;</li>
* <li>any integer-indexed elements in $b will be appended to $a and reindxed accordingly;</li>
* <li>any string-indexed elements in $b will overwrite elements in $a with the same index;</li>
* </ul>
*
* @param mixed $data the data to be merged with, must be an array or object implementing Traversable
* @param boolean $recursive whether the merging should be recursive.
* - the dictionary data is saved as $a, and the source data is saved as $b;
* - if $a and $b both have an array indexed at the same string key, the arrays will be merged using this algorithm;
* - any integer-indexed elements in $b will be appended to $a;
* - any string-indexed elements in $b will overwrite elements in $a with the same index;
*
* @throws Exception If data is neither an array nor an iterator.
* @param array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @param boolean $recursive whether the merging should be recursive.
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
*/
public
function
mergeWith
(
$data
,
$recursive
=
true
)
{
...
...
@@ -227,9 +227,9 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
foreach
(
$data
as
$key
=>
$value
)
{
$d
[
$key
]
=
$value
;
}
$this
->
_d
=
self
::
mergeArray
(
$this
->
_d
,
$d
);
$this
->
_d
=
ArrayHelper
::
merge
(
$this
->
_d
,
$d
);
}
else
{
$this
->
_d
=
self
::
mergeArray
(
$this
->
_d
,
$data
);
$this
->
_d
=
ArrayHelper
::
merge
(
$this
->
_d
,
$data
);
}
}
else
{
foreach
(
$data
as
$key
=>
$value
)
{
...
...
@@ -237,7 +237,7 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
}
}
}
else
{
throw
new
Exception
(
'
Dictionary data
must be an array or an object implementing Traversable.'
);
throw
new
Exception
(
'
The data to be merged with
must be an array or an object implementing Traversable.'
);
}
}
...
...
@@ -293,31 +293,4 @@ class Dictionary extends Object implements \IteratorAggregate, \ArrayAccess, \Co
{
$this
->
remove
(
$offset
);
}
/**
* Merges two arrays into one recursively.
* If each array has an element with the same string key value, the latter
* will overwrite the former (different from array_merge_recursive).
* Recursive merging will be conducted if both arrays have an element of array
* type and are having the same key.
* For integer-keyed elements, the elements from the latter array will
* be appended to the former array.
* @param array $a array to be merged to
* @param array $b array to be merged from
* @return array the merged array (the original arrays are not changed.)
* @see mergeWith
*/
public
static
function
mergeArray
(
$a
,
$b
)
{
foreach
(
$b
as
$k
=>
$v
)
{
if
(
is_integer
(
$k
))
{
isset
(
$a
[
$k
])
?
$a
[]
=
$v
:
$a
[
$k
]
=
$v
;
}
elseif
(
is_array
(
$v
)
&&
isset
(
$a
[
$k
])
&&
is_array
(
$a
[
$k
]))
{
$a
[
$k
]
=
self
::
mergeArray
(
$a
[
$k
],
$v
);
}
else
{
$a
[
$k
]
=
$v
;
}
}
return
$a
;
}
}
framework/base/Module.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Module class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
@@ -13,68 +12,37 @@ namespace yii\base;
/**
* Module is the base class for module and application classes.
*
* Module mainly manages application components and sub-modules.
* Module mainly manages application components and sub-modules
that belongs to a module
.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
abstract
class
Module
extends
Component
abstract
class
Module
extends
Component
implements
Initable
{
/**
* @var array custom module parameters (name => value).
*/
public
$params
=
array
();
/**
* @var array the IDs of the application components that should be preloaded.
* @var array the IDs of the application components that should be preloaded
when this module is created
.
*/
public
$preload
=
array
();
/**
* @var array the behaviors that should be attached to the module.
* The behaviors will be attached to the module when [[init]] is called.
* Please refer to [[Model::behaviors]] on how to specify the value of this property.
*/
public
$behaviors
=
array
();
private
$_id
;
private
$_parentModule
;
private
$_basePath
;
private
$_modulePath
;
private
$_params
;
private
$_parentModule
;
private
$_modules
=
array
();
private
$_moduleConfig
=
array
();
private
$_components
=
array
();
private
$_componentConfig
=
array
();
/**
* Constructor.
* @param string $id the ID of this module
* @param CModule $parent the parent module (if any)
* @param mixed $config the module configuration. It can be either an array or
* the path of a PHP file returning the configuration array.
* @param Module $parent the parent module (if any)
*/
public
function
__construct
(
$id
,
$parent
,
$config
=
null
)
public
function
__construct
(
$id
,
$parent
=
null
)
{
$this
->
_id
=
$id
;
$this
->
_parentModule
=
$parent
;
// set basePath at early as possible to avoid trouble
if
(
is_string
(
$config
))
{
$config
=
require
(
$config
);
}
if
(
isset
(
$config
[
'basePath'
]))
{
$this
->
setBasePath
(
$config
[
'basePath'
]);
unset
(
$config
[
'basePath'
]);
}
Yii
::
setPathOfAlias
(
$id
,
$this
->
getBasePath
());
$this
->
preinit
();
$this
->
configure
(
$config
);
$this
->
attachBehaviors
(
$this
->
behaviors
);
$this
->
preloadComponents
();
$this
->
init
();
}
/**
...
...
@@ -110,16 +78,14 @@ abstract class Module extends Component
}
/**
* Returns a list of behaviors that this model should behave as.
* The return value of this method should be an array of behavior configurations
* indexed by behavior names. For more details, please refer to [[Model::behaviors]].
*
* The declared behaviors will be attached to the module when [[init]] is called.
* @return array the behavior configurations.
* Initializes the module.
* This method is called after the module is created and initialized with property values
* given in configuration.
*/
public
function
behaviors
()
public
function
init
()
{
return
array
();
\Yii
::
setAlias
(
'@'
.
$this
->
getId
(),
$this
->
getBasePath
());
$this
->
preloadComponents
();
}
/**
...
...
@@ -147,7 +113,7 @@ abstract class Module extends Component
public
function
getBasePath
()
{
if
(
$this
->
_basePath
===
null
)
{
$class
=
new
ReflectionClass
(
$this
);
$class
=
new
\
ReflectionClass
(
$this
);
$this
->
_basePath
=
dirname
(
$class
->
getFileName
());
}
return
$this
->
_basePath
;
...
...
@@ -167,31 +133,6 @@ abstract class Module extends Component
}
/**
* Returns the directory that contains child modules.
* @return string the directory that contains child modules. Defaults to the `modules` subdirectory under [[basePath]].
*/
public
function
getModulePath
()
{
if
(
$this
->
_modulePath
!==
null
)
{
return
$this
->
_modulePath
;
}
else
{
return
$this
->
_modulePath
=
$this
->
getBasePath
()
.
DIRECTORY_SEPARATOR
.
'modules'
;
}
}
/**
* Sets the directory that contains child modules.
* @param string $value the directory that contains child modules.
* @throws Exception if the directory is invalid
*/
public
function
setModulePath
(
$value
)
{
if
((
$this
->
_modulePath
=
realpath
(
$value
))
===
false
||
!
is_dir
(
$this
->
_modulePath
))
{
throw
new
Exception
(
'Invalid module path: '
.
$value
);
}
}
/**
* Imports the specified path aliases.
* This method is provided so that you can import a set of path aliases by module configuration.
* @param array $aliases list of path aliases to be imported
...
...
@@ -227,7 +168,7 @@ abstract class Module extends Component
/**
* Returns the parent module.
* @return
CModule the parent module. Null
if this module does not have a parent.
* @return
Module|null the parent module. Null is returned
if this module does not have a parent.
*/
public
function
getParentModule
()
{
...
...
@@ -235,142 +176,154 @@ abstract class Module extends Component
}
/**
* Retrieves the named application module.
* The module has to be declared in {@link modules}. A new instance will be created
* when calling this method with the given ID for the first time.
* @param string $id application module ID (case-sensitive)
* @return CModule the module instance, null if the module is disabled or does not exist.
* Checks whether the named module exists.
* @param string $id module ID
* @return boolean whether the named module exists. Both loaded and unloaded modules
* are considered.
*/
public
function
get
Module
(
$id
)
public
function
has
Module
(
$id
)
{
if
(
isset
(
$this
->
_modules
[
$id
])
||
array_key_exists
(
$id
,
$this
->
_modules
))
{
return
$this
->
_modules
[
$id
];
}
elseif
(
isset
(
$this
->
_moduleConfig
[
$id
]))
{
$config
=
$this
->
_moduleConfig
[
$id
];
if
(
!
isset
(
$config
[
'enabled'
])
||
$config
[
'enabled'
])
{
\Yii
::
trace
(
"Loading
\"
$id
\"
module"
,
'system.base.CModule'
);
$class
=
$config
[
'class'
];
unset
(
$config
[
'class'
],
$config
[
'enabled'
]);
if
(
$this
===
\Yii
::
$app
)
{
$module
=
\Yii
::
createObject
(
$class
,
$id
,
null
,
$config
);
}
else
{
$module
=
\Yii
::
createObject
(
$class
,
$this
->
getId
()
.
'/'
.
$id
,
$this
,
$config
);
}
return
$this
->
_modules
[
$id
]
=
$module
;
return
isset
(
$this
->
_modules
[
$id
]);
}
/**
* Retrieves the named module.
* @param string $id module ID (case-sensitive)
* @param boolean $loadIfNot whether to load the module if it is not yet.
* @return Module|null the module instance, null if the module
* does not exist.
* @see hasModule()
*/
public
function
getModule
(
$id
,
$loadIfNot
=
true
)
{
if
(
isset
(
$this
->
_modules
[
$id
]))
{
if
(
$this
->
_modules
[
$id
]
instanceof
Module
)
{
return
$this
->
_modules
[
$id
];
}
elseif
(
$loadIfNot
)
{
\Yii
::
trace
(
"Loading
\"
$id
\"
module"
,
__CLASS__
);
return
$this
->
_modules
[
$id
]
=
\Yii
::
createObject
(
$this
->
_modules
[
$id
],
$id
,
$this
);
}
}
return
null
;
}
/**
* Returns a value indicating whether the specified module is installed.
* @param string $id the module ID
* @return boolean whether the specified module is installed.
* Adds a sub-module to this module.
* @param string $id module ID
* @param Module|array|null $module the sub-module to be added to this module. This can
* be one of the followings:
*
* - a [[Module]] object
* - a configuration array: when [[getModule()]] is called initially, the array
* will be used to instantiate the sub-module
* - null: the named sub-module will be removed from this module
*/
public
function
hasModule
(
$id
)
public
function
setModule
(
$id
,
$module
)
{
return
isset
(
$this
->
_moduleConfig
[
$id
])
||
isset
(
$this
->
_modules
[
$id
]);
if
(
$module
===
null
)
{
unset
(
$this
->
_modules
[
$id
]);
}
else
{
$this
->
_modules
[
$id
]
=
$module
;
}
}
/**
* Returns the configuration of the currently installed modules.
* @return array the configuration of the currently installed modules (module ID => configuration)
* Returns the sub-modules in this module.
* @param boolean $loadedOnly whether to return the loaded sub-modules only. If this is set false,
* then all sub-modules registered in this module will be returned, whether they are loaded or not.
* Loaded modules will be returned as objects, while unloaded modules as configuration arrays.
* @return array the modules (indexed by their IDs)
*/
public
function
getModules
()
public
function
getModules
(
$loadedOnly
=
false
)
{
return
$this
->
_moduleConfig
;
if
(
$loadedOnly
)
{
$modules
=
array
();
foreach
(
$this
->
_modules
as
$module
)
{
if
(
$module
instanceof
Module
)
{
$modules
[]
=
$module
;
}
}
return
$modules
;
}
else
{
return
$this
->
_modules
;
}
}
/**
*
Configures the sub-modules of this
module.
*
Registers sub-modules in the current
module.
*
*
Call this method to declare sub-modules and configure them with their initial property values.
*
The parameter should be an array of module configurations. Each array element represents a single module,
*
which can be either a string representing the module ID or an ID-configuration pair representing
*
a module with the specified ID and the initial property values
.
*
Each sub-module should be specified as a name-value pair, where
*
name refers to the ID of the module and value the module or a configuration
*
array that can be used to create the module. In the latter case, [[\Yii::createObject()]]
*
will be used to create the module
.
*
* For example, the following array declares two modules:
* <pre>
* array(
* 'admin', // a single module ID
* 'payment'=>array( // ID-configuration pair
* 'server'=>'paymentserver.com',
* ),
* )
* </pre>
* If a new sub-module has the same ID as an existing one, the existing one will be overwritten silently.
*
* By default, the module class is determined using the expression <code>ucfirst($moduleID).'Module'</code>.
* And the class file is located under <code>modules/$moduleID</code>.
* You may override this default by explicitly specifying the 'class' option in the configuration.
* The following is an example for registering two sub-modules:
*
* You may also enable or disable a module by specifying the 'enabled' option in the configuration.
* ~~~
* array(
* 'comment' => array(
* 'class' => 'app\modules\CommentModule',
* 'connectionID' => 'db',
* ),
* 'booking' => array(
* 'class' => 'app\modules\BookingModule',
* ),
* )
* ~~~
*
* @param array $modules module
configurations.
* @param array $modules module
s (id => module configuration or instances)
*/
public
function
setModules
(
$modules
)
{
foreach
(
$modules
as
$id
=>
$module
)
{
if
(
is_int
(
$id
))
{
$id
=
$module
;
$module
=
array
();
}
if
(
!
isset
(
$module
[
'class'
]))
{
Yii
::
setPathOfAlias
(
$id
,
$this
->
getModulePath
()
.
DIRECTORY_SEPARATOR
.
$id
);
$module
[
'class'
]
=
$id
.
'.'
.
ucfirst
(
$id
)
.
'Module'
;
}
if
(
isset
(
$this
->
_moduleConfig
[
$id
]))
{
$this
->
_moduleConfig
[
$id
]
=
CMap
::
mergeArray
(
$this
->
_moduleConfig
[
$id
],
$module
);
}
else
{
$this
->
_moduleConfig
[
$id
]
=
$module
;
}
foreach
(
$modules
as
$id
=>
$module
)
{
$this
->
_modules
[
$id
]
=
$module
;
}
}
/**
* Checks whether the named component exists.
* @param string $id application component ID
* @return boolean whether the named application component exists (including both loaded and disabled.)
* @return boolean whether the named application component exists. Both loaded and unloaded components
* are considered.
*/
public
function
hasComponent
(
$id
)
{
return
isset
(
$this
->
_components
[
$id
])
||
isset
(
$this
->
_componentConfig
[
$id
])
;
return
isset
(
$this
->
_components
[
$id
]);
}
/**
* Retrieves the named application component.
* @param string $id application component ID (case-sensitive)
* @param boolean $
createIfNull whether to create the component if it doesn't exist yet. This parameter
*
has been available since version 1.0.6.
*
@return IApplicationComponent the application component instance, null if the application component is disabled or
does not exist.
* @see hasComponent
* @param boolean $
loadIfNot whether to load the component if it is not yet.
*
@return ApplicationComponent|null the application component instance, null if the application component
* does not exist.
* @see hasComponent
()
*/
public
function
getComponent
(
$id
,
$
createIfNull
=
true
)
public
function
getComponent
(
$id
,
$
loadIfNot
=
true
)
{
if
(
isset
(
$this
->
_components
[
$id
]))
{
return
$this
->
_components
[
$id
];
}
elseif
(
isset
(
$this
->
_componentConfig
[
$id
])
&&
$createIfNull
)
{
$config
=
$this
->
_componentConfig
[
$id
];
if
(
!
isset
(
$config
[
'enabled'
])
||
$config
[
'enabled'
])
{
\Yii
::
trace
(
"Loading
\"
$id
\"
application component"
,
'system.CModule'
);
unset
(
$config
[
'enabled'
]);
$component
=
\Yii
::
createObject
(
$config
);
return
$this
->
_components
[
$id
]
=
$component
;
if
(
$this
->
_components
[
$id
]
instanceof
ApplicationComponent
)
{
return
$this
->
_components
[
$id
];
}
elseif
(
$loadIfNot
)
{
\Yii
::
trace
(
"Loading
\"
$id
\"
application component"
,
__CLASS__
);
return
$this
->
_components
[
$id
]
=
\Yii
::
createObject
(
$this
->
_components
[
$id
]);
}
}
return
null
;
}
/**
* Puts a component under the management of the module.
* The component will be initialized by calling its {@link CApplicationComponent::init() init()}
* method if it has not done so.
* Registers an application component in this module.
* @param string $id component ID
* @param IApplicationComponent $component the component to be added to the module.
* If this parameter is null, it will unload the component from the module.
* @param ApplicationComponent|array|null $component the component to be added to the module. This can
* be one of the followings:
*
* - an [[ApplicationComponent]] object
* - a configuration array: when [[getComponent()]] is called initially for this component, the array
* will be used to instantiate the component
* - null: the named component will be removed from the module
*/
public
function
setComponent
(
$id
,
$component
)
{
...
...
@@ -378,9 +331,6 @@ abstract class Module extends Component
unset
(
$this
->
_components
[
$id
]);
}
else
{
$this
->
_components
[
$id
]
=
$component
;
if
(
!
$component
->
getIsInitialized
())
{
$component
->
init
();
}
}
}
...
...
@@ -389,109 +339,64 @@ abstract class Module extends Component
* @param boolean $loadedOnly whether to return the loaded components only. If this is set false,
* then all components specified in the configuration will be returned, whether they are loaded or not.
* Loaded components will be returned as objects, while unloaded components as configuration arrays.
* This parameter has been available since version 1.1.3.
* @return array the application components (indexed by their IDs)
*/
public
function
getComponents
(
$loadedOnly
=
tru
e
)
public
function
getComponents
(
$loadedOnly
=
fals
e
)
{
if
(
$loadedOnly
)
{
return
$this
->
_components
;
$components
=
array
();
foreach
(
$this
->
_components
as
$component
)
{
if
(
$component
instanceof
ApplicationComponent
)
{
$components
[]
=
$component
;
}
}
return
$components
;
}
else
{
return
array_merge
(
$this
->
_componentConfig
,
$this
->
_components
)
;
return
$this
->
_components
;
}
}
/**
*
Sets the application components
.
*
Registers a set of application components in this module
.
*
*
When a configuration is used to specify a component, it should consist of
*
the component's initial property values (name-value pairs). Additionally,
* a
component can be enabled (default) or disabled by specifying the 'enabled' value
*
in the configuration
.
*
Each application component should be specified as a name-value pair, where
*
name refers to the ID of the component and value the component or a configuration
* a
rray that can be used to create the component. In the latter case, [[\Yii::createObject()]]
*
will be used to create the component
.
*
* If a configuration is specified with an ID that is the same as an existing
* component or configuration, the existing one will be replaced silently.
* If a new component has the same ID as an existing one, the existing one will be overwritten silently.
*
* The following is the configuration for two components:
* <pre>
* The following is an example for setting two components:
*
* ~~~
* array(
* 'db'=>array(
* 'class'=>'CDbConnection',
* 'connectionString'=>'sqlite:path/to/file.db',
* ),
* 'cache'=>array(
* 'class'=>'CDbCache',
* 'connectionID'=>'db',
* 'enabled'=>!YII_DEBUG, // enable caching in non-debug mode
* ),
* 'db' => array(
* 'class' => 'yii\db\dao\Connection',
* 'dsn' => 'sqlite:path/to/file.db',
* ),
* 'cache' => array(
* 'class' => 'yii\caching\DbCache',
* 'connectionID' => 'db',
* ),
* )
*
</pre>
*
~~~
*
* @param array $components application components(id=>component configuration or instances)
* @param boolean $merge whether to merge the new component configuration with the existing one.
* Defaults to true, meaning the previously registered component configuration of the same ID
* will be merged with the new configuration. If false, the existing configuration will be replaced completely.
* @param array $components application components (id => component configuration or instances)
*/
public
function
setComponents
(
$components
,
$merge
=
true
)
public
function
setComponents
(
$components
)
{
foreach
(
$components
as
$id
=>
$component
)
{
if
(
$component
instanceof
IApplicationComponent
)
{
$this
->
setComponent
(
$id
,
$component
);
}
elseif
(
isset
(
$this
->
_componentConfig
[
$id
])
&&
$merge
)
{
$this
->
_componentConfig
[
$id
]
=
CMap
::
mergeArray
(
$this
->
_componentConfig
[
$id
],
$component
);
}
else
{
$this
->
_componentConfig
[
$id
]
=
$component
;
}
}
}
/**
* Configures the module with the specified configuration.
* @param array $config the configuration array
*/
public
function
configure
(
$config
)
{
if
(
is_array
(
$config
))
{
foreach
(
$config
as
$key
=>
$value
)
{
$this
->
$key
=
$value
;
}
foreach
(
$components
as
$id
=>
$component
)
{
$this
->
_components
[
$id
]
=
$component
;
}
}
/**
* Loads
static application components
.
* Loads
application components that are declared in [[preload]]
.
*/
public
function
preloadComponents
()
{
foreach
(
$this
->
preload
as
$id
)
{
foreach
(
$this
->
preload
as
$id
)
{
$this
->
getComponent
(
$id
);
}
}
/**
* Preinitializes the module.
* This method is called at the beginning of the module constructor.
* You may override this method to do some customized preinitialization work.
* Note that at this moment, the module is not configured yet.
* @see init
*/
public
function
preinit
()
{
}
/**
* Initializes the module.
* This method is called at the end of the module constructor.
* Note that at this moment, the module has been configured, the behaviors
* have been attached and the application components have been registered.
* @see preinit
*/
public
function
init
()
{
}
}
framework/base/Vector.php
View file @
409c508f
...
...
@@ -68,7 +68,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
* Returns an iterator for traversing the items in the vector.
* This method is required by the SPL interface `IteratorAggregate`.
* It will be implicitly called when you use `foreach` to traverse the vector.
* @return Iterator an iterator for traversing the items in the vector.
* @return
Vector
Iterator an iterator for traversing the items in the vector.
*/
public
function
getIterator
()
{
...
...
@@ -262,7 +262,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
/**
* Merges iterable data into the vector.
* New items will be appended to the end of the existing items.
* @param
mixed $data the data to be merged with, must be an array or an object implementing `Traversable`
* @param
array|\Traversable $data the data to be merged with. It must be an array or object implementing Traversable
* @throws Exception if data is neither an array nor an object implementing `Traversable`.
*/
public
function
mergeWith
(
$data
)
...
...
@@ -275,7 +275,7 @@ class Vector extends Object implements \IteratorAggregate, \ArrayAccess, \Counta
$this
->
add
(
$item
);
}
}
else
{
throw
new
Exception
(
'
Data must be either
an array or an object implementing Traversable.'
);
throw
new
Exception
(
'
The data to be merged with must be
an array or an object implementing Traversable.'
);
}
}
...
...
framework/db/Exception.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Exception class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/BaseQuery.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* BaseQuery class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/ColumnSchema.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* ColumnSchema class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Command.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Command class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Connection.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Connection class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/DataReader.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* DataReader class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Driver.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Driver class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Expression.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Expression class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Query.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Query class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/QueryBuilder.php
View file @
409c508f
<?php
/**
*
This file contains the Command class
.
*
QueryBuilder class file
.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/TableSchema.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* TableSchema class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/Transaction.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Transaction class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/mysql/Driver.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Driver class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/mysql/QueryBuilder.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* QueryBuilder class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/sqlite/Driver.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Driver class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/db/dao/sqlite/QueryBuilder.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* QueryBuilder class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/DbTarget.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* DbTarget class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/EmailTarget.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* EmailTarget class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/FileTarget.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* FileTarget class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Logger.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Logger class file
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/ProfileTarget.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* CProfileLogRoute class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Router.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Router class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/Target.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* Target class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/logging/WebTarget.php
View file @
409c508f
...
...
@@ -2,7 +2,6 @@
/**
* CWebLogRoute class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
framework/util/ArrayHelper.php
0 → 100644
View file @
409c508f
<?php
/**
* ArrayHelper class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\util
;
/**
* ArrayHelper is ...
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ArrayHelper
extends
\yii\base\Component
{
/**
* Merges two arrays into one recursively.
* If each array has an element with the same string key value, the latter
* will overwrite the former (different from array_merge_recursive).
* Recursive merging will be conducted if both arrays have an element of array
* type and are having the same key.
* For integer-keyed elements, the elements from the latter array will
* be appended to the former array.
* @param array $a array to be merged to
* @param array $b array to be merged from
* @return array the merged array (the original arrays are not changed.)
* @see mergeWith
*/
public
static
function
merge
(
$a
,
$b
)
{
foreach
(
$b
as
$k
=>
$v
)
{
if
(
is_integer
(
$k
))
{
isset
(
$a
[
$k
])
?
$a
[]
=
$v
:
$a
[
$k
]
=
$v
;
}
elseif
(
is_array
(
$v
)
&&
isset
(
$a
[
$k
])
&&
is_array
(
$a
[
$k
]))
{
$a
[
$k
]
=
static
::
merge
(
$a
[
$k
],
$v
);
}
else
{
$a
[
$k
]
=
$v
;
}
}
return
$a
;
}
/**
* Retrieves the value of an array element with the specified key.
*
* If the key does not exist in the array, the default value will be returned instead.
* For example,
*
* ~~~
* $username = \yii\util\ArrayHelper::get($_POST, 'username');
* ~~~
*
* @param array $array array to extract value from
* @param string $key key name of the array element
* @param mixed $default the default value to be returned if the specified key does not exist
* @return mixed
*/
public
static
function
get
(
$array
,
$key
,
$default
=
null
)
{
return
isset
(
$array
[
$key
])
||
array_key_exists
(
$key
,
$array
)
?
$array
[
$key
]
:
$default
;
}
}
\ No newline at end of file
framework/util/File.php
View file @
409c508f
...
...
@@ -2,8 +2,6 @@
/**
* Filesystem helper class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
@@ -14,6 +12,8 @@ namespace yii\util;
/**
* Filesystem helper
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class
File
...
...
framework/util/Text.php
View file @
409c508f
...
...
@@ -2,8 +2,6 @@
/**
* Text helper class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @license http://www.yiiframework.com/license/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment