Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
klimov-paul committed May 30, 2023
1 parent c9bf44d commit 77dd2cb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 39 deletions.
85 changes: 48 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ $configManager = Yii::app()->get('configManager');
$configManager->configure(Yii::app());
```

**Heads up!** Behavior `yii1tech\config\ConfiguresAppFromConfigManager` automatically suppresses any error or exception, which appears during values restoration.
This is done to avoid application blocking in case storage is not yet ready for usage, for example: database table does not yet exist.
Storage failure error will appear only at the application log. You should manually test value restoration is working at your application
to avoid unexpected behavior.


## Configuration items specification <span id="configuration-items-specification"></span>

Expand All @@ -101,57 +106,63 @@ configuration item id (name of key in `\yii1tech\config\Manager::$items` array).
Configuration item may also have several properties, which supports creation of web interface for configuration setup.
These are:

- 'path' - array|string, application component config path.
- 'label' - string, input label.
- 'description' - string, configuration parameter description or input hint.
- 'rules' - array, value validation rules.
- 'inputOptions' - array, list of any other input options.
- 'cast' - string, native type for the value to be cast to.
- 'options' - array, additional descriptive options for this item.

> Tip: since runtime configuration may consist of many items and their declaration may cost a lot of code, it can
be moved into a separated file and specified by this file name.

Here are some examples of item specifications:

```php
'appName' => [
'path' => 'name',
'label' => 'Application Name',
'rules' => [
['required'],
['string'],
],
],
'nullDisplay' => [
'path' => 'components.format.dateFormat',
'label' => 'Date representation format',
'rules' => [
['required'],
['string'],
<?php

return [
'appName' => [
'path' => 'name',
'label' => 'Application Name',
'rules' => [
['required'],
['string'],
],
],
],
'adminEmail' => [
'label' => 'Admin email address',
'rules' => [
['required'],
['email'],
'nullDisplay' => [
'path' => 'components.format.dateFormat',
'label' => 'Date representation format',
'rules' => [
['required'],
['string'],
],
],
],
'adminTheme' => [
'label' => 'Admin interface theme',
'path' => ['modules', 'admin', 'theme'],
'rules' => [
['required'],
['in', 'range' => ['classic', 'bootstrap']],
'adminEmail' => [
'label' => 'Admin email address',
'rules' => [
['required'],
['email'],
],
],
'options' => [
'type' => 'dropDown',
'items' => [
'classic' => 'Classic',
'bootstrap' => 'Twitter Bootstrap',
'adminTheme' => [
'label' => 'Admin interface theme',
'path' => ['modules', 'admin', 'theme'],
'rules' => [
['required'],
['in', 'range' => ['classic', 'bootstrap']],
],
'options' => [
'type' => 'dropDown',
'items' => [
'classic' => 'Classic',
'bootstrap' => 'Twitter Bootstrap',
],
],
],
],
];
```

> Tip: since runtime configuration may consist of many items and their declaration may cost a lot of code, it can
be moved into a separated file and specified by this file name.


## Configuration storage <span id="configuration-storage"></span>

Expand Down
8 changes: 6 additions & 2 deletions src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ class Item extends CModel
* @var string|array application config path. Path is sequence of the config array keys.
* It could be either a string, where keys are separated by '.', or an array of keys.
* For example:
*
* ```
* 'params.myparam';
* array('params', 'myparam');
* ['params', 'myparam'];
* 'components.securityManager.validationKey';
* array('components', 'securityManager', 'validationKey');
* ['components', 'securityManager', 'validationKey'];
* ```
*
* If path is not set it will point to {@see \CApplication::$params} with the key equals ot {@see $id}.
*/
public $path;
Expand Down

0 comments on commit 77dd2cb

Please sign in to comment.