From 29973c57f50bfb707ba25e3d02f343670e2ea2b4 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 3 May 2014 20:50:23 -0400 Subject: [PATCH] added anchors to guide. [skip ci] --- docs/guide/concept-aliases.md | 5 +++++ docs/guide/concept-behaviors.md | 11 +++++++++++ docs/guide/concept-configurations.md | 7 +++++++ docs/guide/concept-events.md | 10 ++++++++++ 4 files changed, 33 insertions(+) diff --git a/docs/guide/concept-aliases.md b/docs/guide/concept-aliases.md index 28561576f1..87fa324e1b 100644 --- a/docs/guide/concept-aliases.md +++ b/docs/guide/concept-aliases.md @@ -7,6 +7,7 @@ For example, the alias `@yii` represents the installation path of the Yii framew the base URL for the currently running Web application. + Defining Aliases ---------------- @@ -49,6 +50,7 @@ return [ ``` + Resolving Aliases ----------------- @@ -81,6 +83,7 @@ Yii::getAlias('@foo/bar/file.php'); // displays: /path2/bar/file.php If `@foo/bar` is not defined as a root alias, the last statement would display `/path/to/foo/bar/file.php`. + Using Aliases ------------- @@ -100,6 +103,7 @@ $cache = new FileCache([ Please pay attention to the API documentation to see if a property or method parameter supports aliases. + Predefined Aliases ------------------ @@ -118,6 +122,7 @@ while the rest of the aliases are defined in the application constructor when ap [configuration](concept-configurations.md). + Extension Aliases ----------------- diff --git a/docs/guide/concept-behaviors.md b/docs/guide/concept-behaviors.md index e2e38bbeb6..28429acaef 100644 --- a/docs/guide/concept-behaviors.md +++ b/docs/guide/concept-behaviors.md @@ -10,6 +10,7 @@ can respond to the [events](concept-events.md) triggered by the component so tha code execution of the component. + Using Behaviors --------------- @@ -54,6 +55,7 @@ $behaviors = $component->getBehaviors(); ``` + Attaching Behaviors ------------------- @@ -126,7 +128,11 @@ $component->attachBehavior('myBehavior3', [ ]); ``` +You may also attach behaviors through [configurations](concept-configurations.md). For more details, please +refer to the [Configurations](concept-configurations.md#configuration-format) chapter. + + Detaching Behaviors ------------------- @@ -143,6 +149,7 @@ $component->detachBehaviors(); ``` + Defining Behaviors ------------------ @@ -228,6 +235,7 @@ function ($event) { ``` + Using `TimestampBehavior` ------------------------- @@ -286,6 +294,7 @@ $user->touch('login_time'); ``` + Comparison with Traits ---------------------- @@ -294,6 +303,7 @@ properties and methods to the primary class, they differ in many aspects. As exp both have pros and cons. They are more like complements rather than replacements to each other. + ### Pros for Behaviors Behavior classes, like normal classes, support inheritance. Traits, on the other hand, @@ -312,6 +322,7 @@ Name conflict caused by different traits requires you to manually resolve it by properties or methods. + ### Pros for Traits Traits are much more efficient than behaviors because behaviors are objects which take both time and memory. diff --git a/docs/guide/concept-configurations.md b/docs/guide/concept-configurations.md index 90b587e926..a846ad0778 100644 --- a/docs/guide/concept-configurations.md +++ b/docs/guide/concept-configurations.md @@ -35,6 +35,7 @@ Yii::configure($object, $config); Note that in this case, the configuration should not contain the `class` element. + Configuration Format -------------------- @@ -79,6 +80,7 @@ Below is an example showing a configuration with property initial values, event ``` + Using Configurations -------------------- @@ -87,6 +89,7 @@ create an object according to a configuration by using [[Yii::createObject()]]. describe application configurations and widget configurations - two major usages of configurations. + ### Application Configurations Configuration for an [application](structure-applications.md) is probably one of the most complex configurations. @@ -138,6 +141,7 @@ For more details about configuring the `components` property of an application c in the [Applications](structure-applications.md) chapter and the [Service Locator](concept-service-locator.md) chapter. + ### Widget Configurations When using [widgets](structure-widgets.md), you often need to use configurations to customize the widget properties. @@ -163,6 +167,7 @@ The `items` property is also configured with menu items to be displayed. Note that because the class name is already given, the configuration array should NOT have the `class` key. + Configuration Files ------------------- @@ -217,6 +222,7 @@ $config = require('path/to/web.php'); ``` + Default Configurations ---------------------- @@ -238,6 +244,7 @@ Without using default configurations, you would have to configure `maxButtonCoun link pagers. + Environment Constants --------------------- diff --git a/docs/guide/concept-events.md b/docs/guide/concept-events.md index 94f352919d..82449ddd0a 100644 --- a/docs/guide/concept-events.md +++ b/docs/guide/concept-events.md @@ -10,6 +10,7 @@ Yii introduces a base class called [[yii\base\Component]] to support events. If events, it should extend from [[yii\base\Component]] or its child class. + Triggering Events ----------------- @@ -76,6 +77,7 @@ When the [[yii\base\Component::trigger()]] method is called, it will call handle the named event. + Event Handlers -------------- @@ -102,6 +104,7 @@ Through the `$event` parameter, an event handler may get the following informati - [[yii\base\Event::data|custom data]]: the data that is provided when attaching the event handler (to be explained shortly). + Attaching Event Handlers ------------------------ @@ -125,6 +128,10 @@ $foo->on(Foo::EVENT_HELLO, function ($event) { }); ``` +You may also attach event handlers through [configurations](concept-configurations.md). For more details, please +refer to the [Configurations](concept-configurations.md#configuration-format) chapter. + + When attaching an event handler, you may provide additional data as the third parameter to [[yii\base\Component::on()]]. The data will be made available to the handler when the event is triggered and the handler is called. For example, @@ -159,6 +166,7 @@ $foo->on(Foo::EVENT_HELLO, function ($event) { ``` + Detaching Event Handlers ------------------------ @@ -189,6 +197,7 @@ $foo->off(Foo::EVENT_HELLO); ``` + Class-Level Event Handlers -------------------------- @@ -247,6 +256,7 @@ Event::off(Foo::className(), Foo::EVENT_HELLO); ``` + Global Events -------------