Commit 6023232d by Carsten Brandt

editing the guide

small punctation and syntax changes.
parent 1a2e4b19
......@@ -114,7 +114,7 @@ Yii supports a wide range of cache storage. The following is a summary:
All cache components have the same base class [[yii\caching\Cache]] and thus support the following APIs:
* [[yii\caching\Cache::get()|get()]]: retrieves a data item from cache with a specified key. A false
* [[yii\caching\Cache::get()|get()]]: retrieves a data item from cache with a specified key. A `false`
value will be returned if the data item is not found in the cache or is expired/invalidated.
* [[yii\caching\Cache::set()|set()]]: stores a data item identified by a key in cache.
* [[yii\caching\Cache::add()|add()]]: stores a data item identified by a key in cache if the key is not found in the cache.
......@@ -190,7 +190,7 @@ enforcement (e.g. caching space is full and the oldest data are removed). To cha
an expiration parameter when calling [[yii\caching\Cache::set()|set()]] to store a data item. The parameter
indicates for how many seconds the data item can remain valid in the cache. When you call
[[yii\caching\Cache::get()|get()]] to retrieve the data item, if it has passed the expiration time, the method
will return false, indicating the data item is not found in the cache. For example,
will return `false`, indicating the data item is not found in the cache. For example,
```php
// keep the data in cache for at most 45 seconds
......@@ -211,7 +211,7 @@ Besides expiration setting, cached data item may also be invalidated by changes
For example, [[yii\caching\FileDependency]] represents the dependency of a file's modification time.
When this dependency changes, it means the corresponding file is modified. As a result, any outdated
file content found in the cache should be invalidated and the [[yii\caching\Cache::get()|get()]] call
should return false.
should return `false`.
Cache dependencies are represented as objects of [[yii\caching\Dependency]] descendant classes. When you call
[[yii\caching\Cache::set()|set()]] to store a data item in the cache, you can pass along an associated cache
......
......@@ -104,17 +104,18 @@ Predefined Aliases <span id="predefined-aliases"></span>
Yii predefines a set of aliases to easily reference commonly used file paths and URLs:
- `@yii`, the directory where the `BaseYii.php` file is located (also called the framework directory)
- `@app`, the [[yii\base\Application::basePath|base path]] of the currently running application
- `@yii`, the directory where the `BaseYii.php` file is located (also called the framework directory).
- `@app`, the [[yii\base\Application::basePath|base path]] of the currently running application.
- `@runtime`, the [[yii\base\Application::runtimePath|runtime path]] of the currently running application. Defaults to `@app/runtime`.
- `@webroot`, the Web root directory of the currently running Web application. It is determined based on the directory
containing the entry script.
containing the [entry script](structure-entry-scripts.md).
- `@web`, the base URL of the currently running Web application. It has the same value as [[yii\web\Request::baseUrl]].
- `@vendor`, the [[yii\base\Application::vendorPath|Composer vendor directory]]. Defaults to `@app/vendor`.
- `@bower`, the root directory that contains [bower packages](http://bower.io/). Defaults to `@vendor/bower`.
- `@npm`, the root directory that contains [npm packages](https://www.npmjs.org/). Defaults to `@vendor/npm`.
The `@yii` alias is defined when you include the `Yii.php` file in your [entry script](structure-entry-scripts.md). The rest of the aliases are defined in the application constructor when applying the application
The `@yii` alias is defined when you include the `Yii.php` file in your [entry script](structure-entry-scripts.md).
The rest of the aliases are defined in the application constructor when applying the application
[configuration](concept-configurations.md).
......
......@@ -15,11 +15,11 @@ Using the Yii Autoloader <span id="using-yii-autoloader"></span>
To make use of the Yii class autoloader, you should follow two simple rules when creating and naming your classes:
* Each class must be under a namespace (e.g. `foo\bar\MyClass`)
* Each class must be under a [namespace](http://php.net/manual/en/language.namespaces.php) (e.g. `foo\bar\MyClass`)
* Each class must be saved in an individual file whose path is determined by the following algorithm:
```php
// $className is a fully qualified class name with the leading backslash
// $className is a fully qualified class name without the leading backslash
$classFile = Yii::getAlias('@' . str_replace('\\', '/', $className) . '.php');
```
......@@ -33,7 +33,8 @@ namespace `app` so that they can be autoloaded by Yii without the need of defini
can be resolved into the class file `AppBasePath/components/MyClass.php`, according to the algorithm just described.
In the [Advanced Application Template](tutorial-advanced-app.md), each tier has its own root alias. For example,
the front-end tier has a root alias `@frontend`, while the back-end tier root alias is `@backend`. As a result, you may put the front-end classes under the namespace `frontend` while the back-end classes are under `backend`. This will
the front-end tier has a root alias `@frontend`, while the back-end tier root alias is `@backend`. As a result,
you may put the front-end classes under the namespace `frontend` while the back-end classes are under `backend`. This will
allow these classes to be autoloaded by the Yii autoloader.
......
......@@ -316,7 +316,8 @@ both have pros and cons. They are more like complements to each other rather tha
Behavior classes, like normal classes, support inheritance. Traits, on the other hand,
can be considered as language-supported copy and paste. They do not support inheritance.
Behaviors can be attached and detached to a component dynamically without requiring modification of the component class. To use a trait, you must modify the class using it.
Behaviors can be attached and detached to a component dynamically without requiring modification of the component class.
To use a trait, you must modify the code of the class using it.
Behaviors are configurable while traits are not.
......
......@@ -8,7 +8,8 @@ or an extended class. The three main features that components provide to other c
* [Events](concept-events.md)
* [Behaviors](concept-behaviors.md)
Separately and combined, these features make Yii classes much more customizable and easier to use. For example, the included [[yii\jui\DatePicker|date picker widget]], a user interface component, can be used in a [view](structure-view.md)
Separately and combined, these features make Yii classes much more customizable and easier to use. For example,
the included [[yii\jui\DatePicker|date picker widget]], a user interface component, can be used in a [view](structure-view.md)
to generate an interactive date picker:
```php
......@@ -42,6 +43,8 @@ these conventions:
For example:
```php
<?php
namespace yii\components\MyClass;
use yii\base\Object;
......@@ -79,7 +82,8 @@ $component = \Yii::createObject([
], [1, 2]);
```
> Info: While the approach of calling [[Yii::createObject()]] looks more complicated, it is more powerful because it is implemented on top of a [dependency injection container](concept-di-container.md).
> Info: While the approach of calling [[Yii::createObject()]] looks more complicated, it is more powerful because it is
> implemented on top of a [dependency injection container](concept-di-container.md).
The [[yii\base\Object]] class enforces the following object lifecycle:
......
Configurations
==============
Configurations are widely used in Yii when creating new objects or initializing existing objects. Configurations usually include the class name of the object being created, and a list of initial values
Configurations are widely used in Yii when creating new objects or initializing existing objects.
Configurations usually include the class name of the object being created, and a list of initial values
that should be assigned to the object's [properties](concept-properties.md). Configurations may also include a list of
handlers that should be attached to the object's [events](concept-events.md) and/or a list of
[behaviors](concept-behaviors.md) that should also be attached to the object.
......@@ -20,7 +21,8 @@ $config = [
$db = Yii::createObject($config);
```
The [[Yii::createObject()]] method takes a configuration array as its argument, and creates an object by instantiating the class named in the configuration. When the object is instantiated, the rest of the configuration
The [[Yii::createObject()]] method takes a configuration array as its argument, and creates an object by instantiating
the class named in the configuration. When the object is instantiated, the rest of the configuration
will be used to initialize the object's properties, event handlers, and behaviors.
If you already have an object, you may use [[Yii::configure()]] to initialize the object's properties with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment