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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
55e8db9b
Commit
55e8db9b
authored
Apr 10, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved doc.
parent
122bd231
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
9 deletions
+31
-9
Component.md
docs/api/base/Component.md
+2
-0
Object.md
docs/api/base/Object.md
+29
-1
Component.php
framework/base/Component.php
+0
-5
Object.php
framework/base/Object.php
+0
-3
No files found.
docs/api/base/Component.md
View file @
55e8db9b
Component is the base class that implements the
*property*
,
*event*
and
*behavior*
features.
Component provides the
*event*
and
*behavior*
features, in addition to the
*property*
feature which is implemented in
its parent class
[
[Object
]
].
...
...
docs/api/base/Object.md
View file @
55e8db9b
Object is the base class that implements the
*property*
feature.
A property is defined by a getter method (e.g.
`getLabel`
), and/or a setter method (e.g.
`setLabel`
). For example,
the following getter and setter methods define a property named
`label`
:
...
...
@@ -30,4 +32,30 @@ $object->label = 'abc';
If a property has only a getter method and has no setter method, it is considered as
*read-only*
. In this case, trying
to modify the property value will cause an exception.
One can call
[
[hasProperty
]
],
[
[canGetProperty
]
] and/or
[
[canSetProperty
]
] to check the existence of a property.
One can call
[
[hasProperty()
]
],
[
[canGetProperty()
]
] and/or
[
[canSetProperty()
]
] to check the existence of a property.
Besides the property feature, Object also introduces an important object initialization life cycle. In particular,
creating an new instance of Object or its derived class will involve the following life cycles sequentially:
1.
the class constructor is invoked;
2.
object properties are initialized according to the given configuration;
3.
the
`init()`
method is invoked.
In the above, both Step 2 and 3 occur at the end of the class constructor. It is recommended that
you perform object initialization in the
`init()`
method because at that stage, the object configuration
is already applied.
In order to ensure the above life cycles, if a child class of Object needs to override the constructor,
it should be done like the following:
~~~
public function __construct($param1, $param2, ..., $config = array())
{
...
parent::__construct($config);
}
~~~
That is, a
`$config`
parameter (defaults to
`array()`
) should be declared as the last parameter
of the constructor, and the parent implementation should be called at the end of the constructor.
framework/base/Component.php
View file @
55e8db9b
...
...
@@ -10,12 +10,7 @@ namespace yii\base;
use
Yii
;
/**
* Component is the base class that provides the *property*, *event* and *behavior* features.
*
* @include @yii/base/Component.md
*
* @property Behavior[] behaviors list of behaviors currently attached to this component
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
framework/base/Object.php
View file @
55e8db9b
...
...
@@ -8,10 +8,7 @@
namespace
yii\base
;
/**
* Object is the base class that provides the *property* feature.
*
* @include @yii/base/Object.md
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
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