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
56c46f62
Commit
56c46f62
authored
May 03, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed basic concept chapter names.
parent
e645b837
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
37 additions
and
37 deletions
+37
-37
README.md
docs/guide/README.md
+9
-9
basic-configs.md
docs/guide/basic-configs.md
+9
-9
concept-aliases.md
docs/guide/concept-aliases.md
+2
-2
concept-autoloading.md
docs/guide/concept-autoloading.md
+0
-0
concept-behaviors.md
docs/guide/concept-behaviors.md
+5
-5
concept-components.md
docs/guide/concept-components.md
+6
-6
concept-di-container.md
docs/guide/concept-di-container.md
+0
-0
concept-events.md
docs/guide/concept-events.md
+0
-0
concept-properties.md
docs/guide/concept-properties.md
+0
-0
concept-service-locator.md
docs/guide/concept-service-locator.md
+0
-0
db-active-record.md
docs/guide/db-active-record.md
+1
-1
intro-upgrade-from-v1.md
docs/guide/intro-upgrade-from-v1.md
+5
-5
No files found.
docs/guide/README.md
View file @
56c46f62
...
@@ -53,15 +53,15 @@ Handling Requests
...
@@ -53,15 +53,15 @@ Handling Requests
Key Concepts
Key Concepts
------------
------------
*
[
Components
](
basic
-components.md
)
*
[
Components
](
concept
-components.md
)
*
[
Properties
](
basic
-properties.md
)
*
[
Properties
](
concept
-properties.md
)
*
[
Events
](
basic
-events.md
)
*
[
Events
](
concept
-events.md
)
*
[
Behaviors
](
basic
-behaviors.md
)
*
[
Behaviors
](
concept
-behaviors.md
)
*
[
Configurations
](
basic
-configs.md
)
*
[
Configurations
](
concept
-configs.md
)
*
[
Aliases
](
basic-alia
s.md
)
*
[
Aliases
](
concept-aliase
s.md
)
*
[
Class Autoloading
](
basic
-autoloading.md
)
*
[
Class Autoloading
](
concept
-autoloading.md
)
*
[
Service Locator
](
basic
-service-locator.md
)
*
[
Service Locator
](
concept
-service-locator.md
)
*
[
Dependency Injection Container
](
basic
-di-container.md
)
*
[
Dependency Injection Container
](
concept
-di-container.md
)
Working with Databases
Working with Databases
...
...
docs/guide/basic-configs.md
View file @
56c46f62
...
@@ -3,9 +3,9 @@ Configurations
...
@@ -3,9 +3,9 @@ Configurations
Configurations are widely used in Yii for creating new objects or initializing existing objects.
Configurations are widely used in Yii for creating new objects or initializing existing objects.
They usually include the class names of the objects being created and a list of initial values
They usually include the class names of the objects being created and a list of initial values
that should be assigned to object
[
properties
](
basic
-properties.md
)
. They may also include a list of
that should be assigned to object
[
properties
](
concept
-properties.md
)
. They may also include a list of
handlers that should be attached to the object
[
events
](
basic
-events.md
)
, and/or a list of
handlers that should be attached to the object
[
events
](
concept
-events.md
)
, and/or a list of
[
behaviors
](
basic
-behaviors.md
)
that should be attached to the objects.
[
behaviors
](
concept
-behaviors.md
)
that should be attached to the objects.
In the following, a configuration is used to create and initialize a DB connection:
In the following, a configuration is used to create and initialize a DB connection:
...
@@ -53,12 +53,12 @@ where
...
@@ -53,12 +53,12 @@ where
*
The
`class`
element specifies a fully qualified class name for the object being created.
*
The
`class`
element specifies a fully qualified class name for the object being created.
*
The
`propertyName`
elements specify the property initial values. The keys are the property names, and the
*
The
`propertyName`
elements specify the property initial values. The keys are the property names, and the
values are the corresponding initial values. Only public member variables and
[
properties
](
basic
-properties.md
)
values are the corresponding initial values. Only public member variables and
[
properties
](
concept
-properties.md
)
defined by getters/setters can be configured.
defined by getters/setters can be configured.
*
The
`on eventName`
elements specify what handlers should be attached to the object
[
events
](
basic
-events.md
)
.
*
The
`on eventName`
elements specify what handlers should be attached to the object
[
events
](
concept
-events.md
)
.
Notice that the array keys are formed by prefixing event names with
`on `
. Please refer to
Notice that the array keys are formed by prefixing event names with
`on `
. Please refer to
the
[
Events
](
basic
-events.md
)
chapter for supported event handler formats.
the
[
Events
](
concept
-events.md
)
chapter for supported event handler formats.
*
And the
`as behaviorName`
elements specify what
[
behaviors
](
basic
-behaviors.md
)
should be attached to the object.
*
And the
`as behaviorName`
elements specify what
[
behaviors
](
concept
-behaviors.md
)
should be attached to the object.
Notice that the array keys are formed by prefixing behavior names with
`on `
.
`$behaviorConfig`
represents
Notice that the array keys are formed by prefixing behavior names with
`on `
.
`$behaviorConfig`
represents
the configuration for creating a behavior, like a normal configuration as we are describing here.
the configuration for creating a behavior, like a normal configuration as we are describing here.
...
@@ -135,7 +135,7 @@ an [entry script](structure-entry-scripts.md), where the class name is already g
...
@@ -135,7 +135,7 @@ an [entry script](structure-entry-scripts.md), where the class name is already g
```
```
For more details about configuring the
`components`
property of an application can be found
For more details about configuring the
`components`
property of an application can be found
in the
[
Applications
](
structure-applications.md
)
chapter and the
[
Service Locator
](
basic
-service-locator.md
)
chapter.
in the
[
Applications
](
structure-applications.md
)
chapter and the
[
Service Locator
](
concept
-service-locator.md
)
chapter.
### Widget Configurations
### Widget Configurations
...
@@ -220,7 +220,7 @@ $config = require('path/to/web.php');
...
@@ -220,7 +220,7 @@ $config = require('path/to/web.php');
Default Configurations
Default Configurations
----------------------
----------------------
The
[
[Yii::createObject()
]
] method is implemented based on a
[
dependency injection container
](
basic
-di-container.md
)
.
The
[
[Yii::createObject()
]
] method is implemented based on a
[
dependency injection container
](
concept
-di-container.md
)
.
It allows you specify a set of the so-called
*default configurations*
which will be applied to ANY instances of
It allows you specify a set of the so-called
*default configurations*
which will be applied to ANY instances of
the specified classes when they are being created using
[
[Yii::createObject()
]
]. The default configurations
the specified classes when they are being created using
[
[Yii::createObject()
]
]. The default configurations
can be specified by calling
`Yii::$container->set()`
in the
[
bootstrapping
](
runtime-bootstrapping.md
)
code.
can be specified by calling
`Yii::$container->set()`
in the
[
bootstrapping
](
runtime-bootstrapping.md
)
code.
...
...
docs/guide/
basic
-aliases.md
→
docs/guide/
concept
-aliases.md
View file @
56c46f62
...
@@ -36,7 +36,7 @@ Yii::setAlias('@foobar', '@foo/bar');
...
@@ -36,7 +36,7 @@ Yii::setAlias('@foobar', '@foo/bar');
Root aliases are usually defined during the
[
bootstrapping
](
runtime-bootstrapping.md
)
stage.
Root aliases are usually defined during the
[
bootstrapping
](
runtime-bootstrapping.md
)
stage.
For example, you may call
[
[Yii::setAlias()
]
] in the
[
entry script
](
structure-entry-scripts.md
)
.
For example, you may call
[
[Yii::setAlias()
]
] in the
[
entry script
](
structure-entry-scripts.md
)
.
For convenience,
[
Application
](
structure-applications.md
)
provides writable property named
`aliases`
For convenience,
[
Application
](
structure-applications.md
)
provides writable property named
`aliases`
that you can configure in the application
[
configuration
](
basic
-configs.md
)
, like the following,
that you can configure in the application
[
configuration
](
concept
-configs.md
)
, like the following,
```
php
```
php
return
[
return
[
...
@@ -115,7 +115,7 @@ The following is the list of the predefined aliases:
...
@@ -115,7 +115,7 @@ The following is the list of the predefined aliases:
The
`@yii`
alias is defined when you include the
`Yii.php`
file in your
[
entry script
](
structure-entry-scripts.md
)
,
The
`@yii`
alias is defined when you include the
`Yii.php`
file in your
[
entry script
](
structure-entry-scripts.md
)
,
while the rest of the aliases are defined in the application constructor when applying the application
while the rest of the aliases are defined in the application constructor when applying the application
[
configuration
](
basic
-configs.md
)
.
[
configuration
](
concept
-configs.md
)
.
Extension Aliases
Extension Aliases
...
...
docs/guide/
basic
-autoloading.md
→
docs/guide/
concept
-autoloading.md
View file @
56c46f62
File moved
docs/guide/
basic
-behaviors.md
→
docs/guide/
concept
-behaviors.md
View file @
56c46f62
...
@@ -6,7 +6,7 @@ as [mixins](http://en.wikipedia.org/wiki/Mixin), allow you to enhance the functi
...
@@ -6,7 +6,7 @@ as [mixins](http://en.wikipedia.org/wiki/Mixin), allow you to enhance the functi
of an existing
[
[yii\base\Component|component
]
] class without the need of changing its class inheritance.
of an existing
[
[yii\base\Component|component
]
] class without the need of changing its class inheritance.
When a behavior is attached to a component, it will "inject" its methods and properties into the component,
When a behavior is attached to a component, it will "inject" its methods and properties into the component,
and you can access these methods and properties as if they are defined by the component class. Moreover, a behavior
and you can access these methods and properties as if they are defined by the component class. Moreover, a behavior
can respond to the
[
events
](
basic
-events.md
)
triggered by the component so that it can customize or adapt the normal
can respond to the
[
events
](
concept
-events.md
)
triggered by the component so that it can customize or adapt the normal
code execution of the component.
code execution of the component.
...
@@ -18,7 +18,7 @@ attach a behavior in the next section.
...
@@ -18,7 +18,7 @@ attach a behavior in the next section.
Once a behavior is attached to a component, its usage is straightforward.
Once a behavior is attached to a component, its usage is straightforward.
You can access a
*public*
member variable or a
[
property
](
basic
-properties.md
)
defined by a getter and/or a setter
You can access a
*public*
member variable or a
[
property
](
concept
-properties.md
)
defined by a getter and/or a setter
of the behavior through the component it is attached to, like the following,
of the behavior through the component it is attached to, like the following,
```
php
```
php
...
@@ -98,7 +98,7 @@ class User extends ActiveRecord
...
@@ -98,7 +98,7 @@ class User extends ActiveRecord
}
}
```
```
The
[
[yii\base\Component::behaviors()|behaviors()
]
] method should return a list of behavior
[
configurations
](
basic
-configs.md
)
.
The
[
[yii\base\Component::behaviors()|behaviors()
]
] method should return a list of behavior
[
configurations
](
concept
-configs.md
)
.
Each behavior configuration can be either a behavior class name or a configuration array.
Each behavior configuration can be either a behavior class name or a configuration array.
You may associate a name with a behavior by specifying the array key corresponding to the behavior configuration.
You may associate a name with a behavior by specifying the array key corresponding to the behavior configuration.
...
@@ -180,7 +180,7 @@ class MyBehavior extends Behavior
...
@@ -180,7 +180,7 @@ class MyBehavior extends Behavior
The above code defines the behavior class
`app\components\MyBehavior`
which will provides two properties
The above code defines the behavior class
`app\components\MyBehavior`
which will provides two properties
`prop1`
and
`prop2`
, and one method
`foo()`
to the component it is attached to. Note that property
`prop2`
`prop1`
and
`prop2`
, and one method
`foo()`
to the component it is attached to. Note that property
`prop2`
is defined via the getter
`getProp2()`
and the setter
`setProp2()`
. This is so because
[
[yii\base\Object
]
]
is defined via the getter
`getProp2()`
and the setter
`setProp2()`
. This is so because
[
[yii\base\Object
]
]
is an ancestor class of
[
[yii\base\Behavior
]
], which supports defining
[
properties
](
basic
-properties.md
)
by getters/setters.
is an ancestor class of
[
[yii\base\Behavior
]
], which supports defining
[
properties
](
concept
-properties.md
)
by getters/setters.
Within a behavior, you can access the component that the behavior is attached to through the
[
[yii\base\Behavior::owner
]
] property.
Within a behavior, you can access the component that the behavior is attached to through the
[
[yii\base\Behavior::owner
]
] property.
...
@@ -220,7 +220,7 @@ its handler `beforeValidate()`. When specifying an event handler, you may use on
...
@@ -220,7 +220,7 @@ its handler `beforeValidate()`. When specifying an event handler, you may use on
*
an anonymous function.
*
an anonymous function.
The signature of an event handler should be as follows, where
`$event`
refers to the event parameter. Please refer
The signature of an event handler should be as follows, where
`$event`
refers to the event parameter. Please refer
to the
[
Events
](
basic
-events.md
)
chapter for more details about events.
to the
[
Events
](
concept
-events.md
)
chapter for more details about events.
```
php
```
php
function
(
$event
)
{
function
(
$event
)
{
...
...
docs/guide/
basic
-components.md
→
docs/guide/
concept
-components.md
View file @
56c46f62
...
@@ -2,8 +2,8 @@ Components
...
@@ -2,8 +2,8 @@ Components
==========
==========
Components are the main building blocks in Yii applications. Components are instances of
[
[yii\base\Component
]
]
Components are the main building blocks in Yii applications. Components are instances of
[
[yii\base\Component
]
]
or it child class. They support features such as
[
properties
](
basic-properties.md
)
,
[
events
](
basic
-events.md
)
and
or it child class. They support features such as
[
properties
](
concept-properties.md
)
,
[
events
](
concept
-events.md
)
and
[
behaviors
](
basic
-behaviors.md
)
, which makes them more customizable and easier to use. For example, you may use
[
behaviors
](
concept
-behaviors.md
)
, which makes them more customizable and easier to use. For example, you may use
the included
[
[yii\jui\DatePicker|date picker widget
]
], a user interface component, in a
[
view
](
structure-view.md
)
the included
[
[yii\jui\DatePicker|date picker widget
]
], a user interface component, in a
[
view
](
structure-view.md
)
to generate an interactive date picker:
to generate an interactive date picker:
...
@@ -20,10 +20,10 @@ echo DatePicker::widget([
...
@@ -20,10 +20,10 @@ echo DatePicker::widget([
```
```
While components are very powerful, they are a bit heavier compared to normal objects, due to the fact that
While components are very powerful, they are a bit heavier compared to normal objects, due to the fact that
it takes extra memory and CPU time in order to support
[
events
](
basic-events.md
)
and
[
behaviors
](
basic
-behaviors.md
)
.
it takes extra memory and CPU time in order to support
[
events
](
concept-events.md
)
and
[
behaviors
](
concept
-behaviors.md
)
.
If your components do not need these two features, you may consider extending your component class from
If your components do not need these two features, you may consider extending your component class from
[
[yii\base\Object
]
] instead of
[
[yii\base\Component
]
], which will make your components as efficient as normal objects,
[
[yii\base\Object
]
] instead of
[
[yii\base\Component
]
], which will make your components as efficient as normal objects,
but with the extra support for
[
properties
](
basic
-properties.md
)
.
but with the extra support for
[
properties
](
concept
-properties.md
)
.
When extending your class from
[
[yii\base\Component
]
] or
[
[yii\base\Object
]
], it is recommended that you follow
When extending your class from
[
[yii\base\Component
]
] or
[
[yii\base\Object
]
], it is recommended that you follow
these conventions:
these conventions:
...
@@ -61,7 +61,7 @@ class MyClass extends Object
...
@@ -61,7 +61,7 @@ class MyClass extends Object
}
}
```
```
This will make your components
[
configurable
](
basic
-configs.md
)
when they are being created. For example,
This will make your components
[
configurable
](
concept
-configs.md
)
when they are being created. For example,
```
php
```
php
$component
=
new
MyClass
(
1
,
2
,
[
'prop1'
=>
3
,
'prop2'
=>
4
]);
$component
=
new
MyClass
(
1
,
2
,
[
'prop1'
=>
3
,
'prop2'
=>
4
]);
...
@@ -74,7 +74,7 @@ $component = \Yii::createObject([
...
@@ -74,7 +74,7 @@ $component = \Yii::createObject([
```
```
> Info: While the call of [[Yii::createObject()]] looks more complicated, it is more powerful due to
> Info: While the call of [[Yii::createObject()]] looks more complicated, it is more powerful due to
the fact that it is implemented on top of a
[
dependency injection container
](
basic
-di-container.md
)
.
the fact that it is implemented on top of a
[
dependency injection container
](
concept
-di-container.md
)
.
The
[
[yii\base\Object
]
] class enforces the following object lifecycle:
The
[
[yii\base\Object
]
] class enforces the following object lifecycle:
...
...
docs/guide/
basic
-di-container.md
→
docs/guide/
concept
-di-container.md
View file @
56c46f62
File moved
docs/guide/
basic
-events.md
→
docs/guide/
concept
-events.md
View file @
56c46f62
File moved
docs/guide/
basic
-properties.md
→
docs/guide/
concept
-properties.md
View file @
56c46f62
File moved
docs/guide/
basic
-service-locator.md
→
docs/guide/
concept
-service-locator.md
View file @
56c46f62
File moved
docs/guide/db-active-record.md
View file @
56c46f62
...
@@ -331,7 +331,7 @@ Active Record Life Cycles
...
@@ -331,7 +331,7 @@ Active Record Life Cycles
It is important to understand the life cycles of Active Record when it is used to manipulate data in database.
It is important to understand the life cycles of Active Record when it is used to manipulate data in database.
These life cycles are typically associated with corresponding events which allow you to inject code
These life cycles are typically associated with corresponding events which allow you to inject code
to intercept or respond to these events. They are especially useful for developing Active Record
[
behaviors
](
basic
-behaviors.md
)
.
to intercept or respond to these events. They are especially useful for developing Active Record
[
behaviors
](
concept
-behaviors.md
)
.
When instantiating a new Active Record instance, we will have the following life cycles:
When instantiating a new Active Record instance, we will have the following life cycles:
...
...
docs/guide/intro-upgrade-from-v1.md
View file @
56c46f62
...
@@ -54,9 +54,9 @@ Component and Object
...
@@ -54,9 +54,9 @@ Component and Object
--------------------
--------------------
Yii 2.0 breaks the
`CComponent`
class in 1.1 into two classes:
[
[yii\base\Object
]
] and
[
[yii\base\Component
]
].
Yii 2.0 breaks the
`CComponent`
class in 1.1 into two classes:
[
[yii\base\Object
]
] and
[
[yii\base\Component
]
].
The
[
[yii\base\Object|Object
]
] class is a lightweight base class that allows defining
[
object properties
](
basic
-properties.md
)
The
[
[yii\base\Object|Object
]
] class is a lightweight base class that allows defining
[
object properties
](
concept
-properties.md
)
via getters and setters. The
[
[yii\base\Component|Component
]
] class extends from
[
[yii\base\Object|Object
]
] and supports
via getters and setters. The
[
[yii\base\Component|Component
]
] class extends from
[
[yii\base\Object|Object
]
] and supports
[
events
](
basic-events.md
)
and
[
behaviors
](
basic
-behaviors.md
)
.
[
events
](
concept-events.md
)
and
[
behaviors
](
concept
-behaviors.md
)
.
If your class does not need the event or behavior feature, you should consider using
If your class does not need the event or behavior feature, you should consider using
[
[yii\base\Object|Object
]
] as the base class. This is usually the case for classes that represent basic
[
[yii\base\Object|Object
]
] as the base class. This is usually the case for classes that represent basic
...
@@ -105,7 +105,7 @@ $object = Yii::createObject([
...
@@ -105,7 +105,7 @@ $object = Yii::createObject([
],
[
$param1
,
$param2
]);
],
[
$param1
,
$param2
]);
```
```
More details about configurations can be found in the
[
Object Configurations
](
basic
-configs.md
)
chapter.
More details about configurations can be found in the
[
Object Configurations
](
concept
-configs.md
)
chapter.
Events
Events
...
@@ -128,7 +128,7 @@ $component->on($eventName, $handler);
...
@@ -128,7 +128,7 @@ $component->on($eventName, $handler);
// $component->off($eventName, $handler);
// $component->off($eventName, $handler);
```
```
There are many enhancements to the event features. For more details, please refer to the
[
Events
](
basic
-events.md
)
chapter.
There are many enhancements to the event features. For more details, please refer to the
[
Events
](
concept
-events.md
)
chapter.
Path Aliases
Path Aliases
...
@@ -147,7 +147,7 @@ a class like `yii\web\Request` can be autoloaded by Yii. If you use a third part
...
@@ -147,7 +147,7 @@ a class like `yii\web\Request` can be autoloaded by Yii. If you use a third part
such as Zend Framework, you may define a path alias
`@Zend`
which refers to its installation
such as Zend Framework, you may define a path alias
`@Zend`
which refers to its installation
directory and Yii will be able to autoload any class in this library.
directory and Yii will be able to autoload any class in this library.
More on path aliases can be found in the
[
Path Aliases
](
basic
-aliases.md
)
chapter.
More on path aliases can be found in the
[
Path Aliases
](
concept
-aliases.md
)
chapter.
Views
Views
...
...
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