From c5a564f0ff5bcfa67688b0ee78852479a7d48bff Mon Sep 17 00:00:00 2001 From: Agrumas Date: Thu, 24 Apr 2014 23:20:24 +0300 Subject: [PATCH 01/43] Lithuanian translation --- framework/messages/lt/yii.php | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 framework/messages/lt/yii.php diff --git a/framework/messages/lt/yii.php b/framework/messages/lt/yii.php new file mode 100644 index 0000000000..3eb169404c --- /dev/null +++ b/framework/messages/lt/yii.php @@ -0,0 +1,81 @@ + 'Peržiūrėti', + '(not set)' => '(nenustatyta)', + 'An internal server error occurred.' => 'Įvyko vidinė serverio klaida', + 'Are you sure to delete this item?' => 'Ar tikrai norite ištrinti šį elementą?', + 'Delete' => 'Ištrinti', + 'Error' => 'Klaida', + 'File upload failed.' => 'Nepavyko įkelti failo.', + 'Home' => 'Pradžia', + 'Invalid data received for parameter "{param}".' => 'Gauti neteisingi duomenys į parametrą "{param}".', + 'Login Required' => 'Būtina prisijungti', + 'Missing required arguments: {params}' => 'Trūksta privalomo argumento: {params}', + 'Missing required parameters: {params}' => 'Trūksta privalomų parametrų: {params}', + 'No' => 'Ne', + 'No help for unknown command "{command}".' => 'Nėra informacijos apie nežinomą "{command}" komandą.', + 'No help for unknown sub-command "{command}".' => 'Nėra informacijos apie nežinomą "{command}" sub komandą', + 'No results found.' => 'Nerasta rezultatų.', + 'Only files with these extensions are allowed: {extensions}.' => 'Leidžiama įkelti failus tik su šiais plėtiniais: {extensions}.', + 'Only files with these mimeTypes are allowed: {mimeTypes}.' => 'Leidžiama įkelti failus tik šių MIME tipų: {mimeTypes}.', + 'Page not found.' => 'Puslapis nerastas.', + 'Please fix the following errors:' => 'Prašytume ištaisyti nurodytas klaidas:', + 'Please upload a file.' => 'Prašome įkelti failą.', + 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => 'Rodomi rezultatai {begin, number}-{end, number}{totalCount, number}.', + 'The file "{file}" is not an image.' => 'Failas „{file}” nėra paveikslėlis.', + 'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}” yra per didelis. Dydis negali viršyti {limit, number} {limit, plural, one{baito} few{baitų} other{baitų}}.', + 'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}” yra per mažas. Izmēram ir jābūt vairāk par {limit, number} {limit, plural, one{baito} few{baitų} other{baitų}}.', + 'The format of {attribute} is invalid.' => 'Atributo „{attribute}” formatas yra netinkamas.', + 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per didelis. Aukštis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', + 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per didelis. Plotis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', + 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per mažas. Aukštis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', + 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per mažas. Plotis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', + 'The verification code is incorrect.' => 'Neteisingas patikrinimo kodas.', + 'Total {count, number} {count, plural, one{item} other{items}}.' => 'Iš viso {count, number} {count, plural, one{elementas} few{elementai} other{elementų}}.', + 'Unable to verify your data submission.' => 'Neįmanoma patikrinti jūsų siunčiamų duomenų.', + 'Unknown command "{command}".' => 'Nežinoma komanda "{command}".', + 'Unknown option: --{name}' => 'Nežinomas pasirinkimas: --{name}', + 'Update' => 'Atnaujinti', + 'Yes' => 'Taip', + 'You are not allowed to perform this action.' => 'Jums neleidžiama atlikti šio veiksmo.', + 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Leidžiama įkelti ne daugiau nei {limit, number} {limit, plural, one{failą} few{failus} other{failų}}.', + 'the input value' => 'įvesties reikšmė', + '{attribute} "{value}" has already been taken.' => '{attribute} reikšmė „{value}” jau naudojama.', + '{attribute} cannot be blank.' => '„{attribute}” negali būti tuščias.', + '{attribute} is invalid.' => '„{attribute}“ reikšmė netinkama.', + '{attribute} is not a valid URL.' => '„{attribute}” įvestas netinkamas URL.', + '{attribute} is not a valid email address.' => '„{attribute}” įvestas netinkamas el. pašto adresas.', + '{attribute} must be "{requiredValue}".' => '„{attribute}” privalo būti „{requiredValue}”.', + '{attribute} must be a number.' => '„{attribute}” privalo būti skaičius.', + '{attribute} must be a string.' => '„{attribute}” privalo būti eilutė.', + '{attribute} must be an integer.' => '„{attribute}” privalo būti sveikas skaičius.', + '{attribute} must be either "{true}" or "{false}".' => '„{attribute}” privalo būti „{true}” arba „{false}”.', + '{attribute} must be greater than "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti didesnė nei „{compareValue}”.', + '{attribute} must be greater than or equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti didesnė arba lygi „{compareValue}”.', + '{attribute} must be less than "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti mažesnė nei „{compareValue}”.', + '{attribute} must be less than or equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti mažesnė arba lygi „{compareValue}”.', + '{attribute} must be no greater than {max}.' => 'Laukelio „{attribute}” reikšmė privalo būti ne didesnė nei {max}.', + '{attribute} must be no less than {min}.' => 'Laukelio „{attribute}” reikšmė privalo būti ne mažesnė nei {min}.', + '{attribute} must be repeated exactly.' => 'Laukelio „{attribute}” reikšmė privalo būti pakartota tiksliai.', + '{attribute} must not be equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė negali būti lygi „{compareValue}”.', + '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti mažiausiai {min, number} {min, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti daugiausiai {max, number} {max, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti {length, number} {length, plural, one{ženklas} few{ženklai} other{ženklų}}.', +); From 6f9aee90ea114b164d806bc320e28e8af3019291 Mon Sep 17 00:00:00 2001 From: johonunu Date: Thu, 1 May 2014 00:15:36 +0200 Subject: [PATCH 02/43] Search model not required anymore in crud generator --- extensions/gii/generators/crud/Generator.php | 13 +++++++++---- .../gii/generators/crud/default/controller.php | 14 ++++++++++++++ .../gii/generators/crud/default/views/index.php | 8 +++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/extensions/gii/generators/crud/Generator.php b/extensions/gii/generators/crud/Generator.php index 90901ec07b..3150a6e8fe 100644 --- a/extensions/gii/generators/crud/Generator.php +++ b/extensions/gii/generators/crud/Generator.php @@ -35,7 +35,7 @@ class Generator extends \yii\gii\Generator public $controllerClass; public $baseControllerClass = 'yii\web\Controller'; public $indexWidgetType = 'grid'; - public $searchModelClass; + public $searchModelClass = ''; /** * @inheritdoc @@ -61,7 +61,7 @@ class Generator extends \yii\gii\Generator { return array_merge(parent::rules(), [ [['moduleID', 'controllerClass', 'modelClass', 'searchModelClass', 'baseControllerClass'], 'filter', 'filter' => 'trim'], - [['modelClass', 'searchModelClass', 'controllerClass', 'baseControllerClass', 'indexWidgetType'], 'required'], + [['modelClass', 'controllerClass', 'baseControllerClass', 'indexWidgetType'], 'required'], [['searchModelClass'], 'compare', 'compareAttribute' => 'modelClass', 'operator' => '!==', 'message' => 'Search Model Class must not be equal to Model Class.'], [['modelClass', 'controllerClass', 'baseControllerClass', 'searchModelClass'], 'match', 'pattern' => '/^[\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'], [['modelClass'], 'validateClass', 'params' => ['extends' => BaseActiveRecord::className()]], @@ -162,15 +162,20 @@ class Generator extends \yii\gii\Generator public function generate() { $controllerFile = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->controllerClass, '\\')) . '.php'); - $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); + $files = [ new CodeFile($controllerFile, $this->render('controller.php')), - new CodeFile($searchModel, $this->render('search.php')), ]; + if(!empty($this->searchModelClass)){ + $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); + $files[] = new CodeFile($searchModel, $this->render('search.php')); + } + $viewPath = $this->getViewPath(); $templatePath = $this->getTemplatePath() . '/views'; foreach (scandir($templatePath) as $file) { + if(empty($this->searchModelClass) && $file==='_search.php') continue; if (is_file($templatePath . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { $files[] = new CodeFile("$viewPath/$file", $this->render("views/$file")); } diff --git a/extensions/gii/generators/crud/default/controller.php b/extensions/gii/generators/crud/default/controller.php index 9bfef66716..209a76d6fd 100644 --- a/extensions/gii/generators/crud/default/controller.php +++ b/extensions/gii/generators/crud/default/controller.php @@ -31,7 +31,11 @@ namespace controllerClass, '\\')) ?> use Yii; use modelClass, '\\') ?>; +searchModelClass)){ ?> use searchModelClass, '\\') . (isset($searchModelAlias) ? " as $searchModelAlias" : "") ?>; + +use yii\data\ActiveDataProvider; + use baseControllerClass, '\\') ?>; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -59,6 +63,7 @@ class extends bas */ public function actionIndex() { +searchModelClass)){ ?> $searchModel = new ; $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); @@ -66,6 +71,15 @@ class extends bas 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); + + $dataProvider = new ActiveDataProvider([ + 'query' => ::find(), + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } /** diff --git a/extensions/gii/generators/crud/default/views/index.php b/extensions/gii/generators/crud/default/views/index.php index 0e6118198b..383f42f868 100644 --- a/extensions/gii/generators/crud/default/views/index.php +++ b/extensions/gii/generators/crud/default/views/index.php @@ -20,7 +20,7 @@ use indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\w /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider - * @var searchModelClass, '\\') ?> $searchModel +searchModelClass)?" * @var ".ltrim($generator->searchModelClass, '\\')." \$searchModel\n":'' ?> */ $this->title = generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>; @@ -29,8 +29,7 @@ $this->params['breadcrumbs'][] = $this->title;

Html::encode($this->title) ?>

- - indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?> + searchModelClass)){ ?>indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?>

Html::a(generateString('Create {modelClass}', ['modelClass' => Inflector::camel2words(StringHelper::basename($generator->modelClass))]) ?>, ['create'], ['class' => 'btn btn-success']) ?> @@ -39,8 +38,7 @@ $this->params['breadcrumbs'][] = $this->title; indexWidgetType === 'grid'): ?> GridView::widget([ 'dataProvider' => $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ + searchModelClass)?"'filterModel' => \$searchModel,\n\t\t'columns' => [\n":"'columns' => [\n"; ?> ['class' => 'yii\grid\SerialColumn'], Date: Thu, 1 May 2014 10:08:11 +0200 Subject: [PATCH 03/43] Reformating code. Removed \t signs, using spaces. Edited Changelog. --- extensions/gii/CHANGELOG.md | 1 + extensions/gii/generators/crud/Generator.php | 10 ++++++---- .../gii/generators/crud/default/controller.php | 12 ++++++------ .../gii/generators/crud/default/views/index.php | 8 +++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/extensions/gii/CHANGELOG.md b/extensions/gii/CHANGELOG.md index 4a3ff11eb3..87eba4b826 100644 --- a/extensions/gii/CHANGELOG.md +++ b/extensions/gii/CHANGELOG.md @@ -27,6 +27,7 @@ Yii Framework 2 gii extension Change Log - Enh #2633: Keyboard shortcuts to browse through files (thiagotalma) - Enh #2822: possibility to generate I18N messages (lucianobaraglia) - Enh #2843: Option to filter files according to the action. (thiagotalma) +- Enh #2018: Search model not required anymore in crud generator. (johonunu) 2.0.0-alpha, December 1, 2013 ----------------------------- diff --git a/extensions/gii/generators/crud/Generator.php b/extensions/gii/generators/crud/Generator.php index 3150a6e8fe..aecc337e4e 100644 --- a/extensions/gii/generators/crud/Generator.php +++ b/extensions/gii/generators/crud/Generator.php @@ -167,7 +167,7 @@ class Generator extends \yii\gii\Generator new CodeFile($controllerFile, $this->render('controller.php')), ]; - if(!empty($this->searchModelClass)){ + if (!empty($this->searchModelClass)) { $searchModel = Yii::getAlias('@' . str_replace('\\', '/', ltrim($this->searchModelClass, '\\') . '.php')); $files[] = new CodeFile($searchModel, $this->render('search.php')); } @@ -175,7 +175,9 @@ class Generator extends \yii\gii\Generator $viewPath = $this->getViewPath(); $templatePath = $this->getTemplatePath() . '/views'; foreach (scandir($templatePath) as $file) { - if(empty($this->searchModelClass) && $file==='_search.php') continue; + if (empty($this->searchModelClass) && $file === '_search.php') { + continue; + } if (is_file($templatePath . '/' . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { $files[] = new CodeFile("$viewPath/$file", $this->render("views/$file")); } @@ -443,7 +445,7 @@ class Generator extends \yii\gii\Generator if (is_subclass_of($class, 'yii\mongodb\ActiveRecord')) { return "'id' => (string)\$model->{$pks[0]}"; } else { - return "'id' => \$model->{$pks[0]}"; + return "'id' => \$model->{$pks[0]}"; } } else { $params = []; @@ -451,7 +453,7 @@ class Generator extends \yii\gii\Generator if (is_subclass_of($class, 'yii\mongodb\ActiveRecord')) { $params[] = "'$pk' => (string)\$model->$pk"; } else { - $params[] = "'$pk' => \$model->$pk"; + $params[] = "'$pk' => \$model->$pk"; } } diff --git a/extensions/gii/generators/crud/default/controller.php b/extensions/gii/generators/crud/default/controller.php index 209a76d6fd..e51e63d7ff 100644 --- a/extensions/gii/generators/crud/default/controller.php +++ b/extensions/gii/generators/crud/default/controller.php @@ -31,11 +31,11 @@ namespace controllerClass, '\\')) ?> use Yii; use modelClass, '\\') ?>; -searchModelClass)){ ?> +searchModelClass)): ?> use searchModelClass, '\\') . (isset($searchModelAlias) ? " as $searchModelAlias" : "") ?>; - + use yii\data\ActiveDataProvider; - + use baseControllerClass, '\\') ?>; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -63,7 +63,7 @@ class extends bas */ public function actionIndex() { -searchModelClass)){ ?> +searchModelClass)): ?> $searchModel = new ; $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); @@ -71,7 +71,7 @@ class extends bas 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); - + $dataProvider = new ActiveDataProvider([ 'query' => ::find(), ]); @@ -79,7 +79,7 @@ class extends bas return $this->render('index', [ 'dataProvider' => $dataProvider, ]); - + } /** diff --git a/extensions/gii/generators/crud/default/views/index.php b/extensions/gii/generators/crud/default/views/index.php index 383f42f868..f56657b2ed 100644 --- a/extensions/gii/generators/crud/default/views/index.php +++ b/extensions/gii/generators/crud/default/views/index.php @@ -20,7 +20,7 @@ use indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\w /** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider -searchModelClass)?" * @var ".ltrim($generator->searchModelClass, '\\')." \$searchModel\n":'' ?> +searchModelClass) ? " * @var " . ltrim($generator->searchModelClass, '\\') . " \$searchModel\n" : '' ?> */ $this->title = generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>; @@ -29,7 +29,9 @@ $this->params['breadcrumbs'][] = $this->title;

Html::encode($this->title) ?>

- searchModelClass)){ ?>indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?> +searchModelClass)): ?> +indexWidgetType === 'grid' ? "// " : "") ?>echo $this->render('_search', ['model' => $searchModel]); ?> +

Html::a(generateString('Create {modelClass}', ['modelClass' => Inflector::camel2words(StringHelper::basename($generator->modelClass))]) ?>, ['create'], ['class' => 'btn btn-success']) ?> @@ -38,7 +40,7 @@ $this->params['breadcrumbs'][] = $this->title; indexWidgetType === 'grid'): ?> GridView::widget([ 'dataProvider' => $dataProvider, - searchModelClass)?"'filterModel' => \$searchModel,\n\t\t'columns' => [\n":"'columns' => [\n"; ?> + searchModelClass) ? "'filterModel' => \$searchModel,\n 'columns' => [\n" : "'columns' => [\n"; ?> ['class' => 'yii\grid\SerialColumn'], Date: Sun, 4 May 2014 10:44:02 +0400 Subject: [PATCH 04/43] Advanced app `init` usage example typo fix --- apps/advanced/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/advanced/init b/apps/advanced/init index a82de2742b..4858321b1a 100755 --- a/apps/advanced/init +++ b/apps/advanced/init @@ -5,7 +5,7 @@ * * In order to run in non-interactive mode: * - * init --env=dev --overwrite=n + * init --env=Development --overwrite=n * * @author Alexander Makarov * From f4cbb1ce939a729eab88c93684847b10bbb20e40 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 4 May 2014 16:00:50 +0200 Subject: [PATCH 05/43] note about advanced app custom aliaes fixes #3342 --- docs/guide/tutorial-advanced-app.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/guide/tutorial-advanced-app.md b/docs/guide/tutorial-advanced-app.md index 88f0c10495..5e7638f7a7 100644 --- a/docs/guide/tutorial-advanced-app.md +++ b/docs/guide/tutorial-advanced-app.md @@ -74,16 +74,20 @@ Root directory contains a set of files. Predefined path aliases ----------------------- -- @yii - framework directory. -- @app - base path of currently running application. -- @common - common directory. -- @frontend - frontend web application directory. -- @backend - backend web application directory. -- @console - console directory. -- @runtime - runtime directory of currently running web application. -- @vendor - Composer vendor directory. -- @web - base URL of currently running web application. -- @webroot - web root directory of currently running web application. +- `@yii` - framework directory. +- `@app` - base path of currently running application. +- `@common` - common directory. +- `@frontend` - frontend web application directory. +- `@backend` - backend web application directory. +- `@console` - console directory. +- `@runtime` - runtime directory of currently running web application. +- `@vendor` - Composer vendor directory. +- `@web` - base URL of currently running web application. +- `@webroot` - web root directory of currently running web application. + +The aliases specific to the directory structure of the advanced application +(`@common`, `@frontend`, `@backend`, `@console`) are defined in `common/config/aliases.php`. + Applications ------------ From e005017ab21de850fc8993b1ca3ad4f39399d931 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 4 May 2014 16:01:28 +0200 Subject: [PATCH 06/43] typo --- docs/guide/tutorial-advanced-app.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/tutorial-advanced-app.md b/docs/guide/tutorial-advanced-app.md index 5e7638f7a7..5726cdce03 100644 --- a/docs/guide/tutorial-advanced-app.md +++ b/docs/guide/tutorial-advanced-app.md @@ -86,7 +86,7 @@ Predefined path aliases - `@webroot` - web root directory of currently running web application. The aliases specific to the directory structure of the advanced application -(`@common`, `@frontend`, `@backend`, `@console`) are defined in `common/config/aliases.php`. +(`@common`, `@frontend`, `@backend`, and `@console`) are defined in `common/config/aliases.php`. Applications From 150eb6b85563a9cd18cc1f776f368ec9a4dbcf53 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 4 May 2014 18:15:51 +0400 Subject: [PATCH 07/43] Fixes #2018: Adjusted changelog --- extensions/gii/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gii/CHANGELOG.md b/extensions/gii/CHANGELOG.md index 87eba4b826..bc2818ed15 100644 --- a/extensions/gii/CHANGELOG.md +++ b/extensions/gii/CHANGELOG.md @@ -6,6 +6,7 @@ Yii Framework 2 gii extension Change Log - Bug #1263: Fixed the issue that Gii and Debug modules might be affected by incompatible asset manager configuration (qiangxue) - Bug #3265: Fixed incorrect controller class name validation (suralc) +- Enh #2018: Search model is not required anymore in CRUD generator (johonunu) - Enh #3088: The gii module will manage their own URL rules now (qiangxue) - Enh #3222: Added `useTablePrefix` option to the model generator for Gii (horizons2) @@ -27,7 +28,6 @@ Yii Framework 2 gii extension Change Log - Enh #2633: Keyboard shortcuts to browse through files (thiagotalma) - Enh #2822: possibility to generate I18N messages (lucianobaraglia) - Enh #2843: Option to filter files according to the action. (thiagotalma) -- Enh #2018: Search model not required anymore in crud generator. (johonunu) 2.0.0-alpha, December 1, 2013 ----------------------------- From f9370204d8030786ba15ee4b8e0c49e40decf53c Mon Sep 17 00:00:00 2001 From: Aoseala Date: Sun, 4 May 2014 23:11:10 +0800 Subject: [PATCH 08/43] Fixes example code symbol errors --- extensions/jui/Tabs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/jui/Tabs.php b/extensions/jui/Tabs.php index f6a5fb7a16..52d70dc053 100644 --- a/extensions/jui/Tabs.php +++ b/extensions/jui/Tabs.php @@ -39,7 +39,7 @@ use yii\helpers\Html; * 'label' => 'Ajax tab', * 'url' => ['ajax/content'], * ], - * ), + * ], * 'options' => ['tag' => 'div'], * 'itemOptions' => ['tag' => 'div'], * 'headerOptions' => ['class' => 'my-class'], From 0b7f649148f6eef0f063544eb7a4fcab0dd11c3d Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 4 May 2014 19:42:23 +0400 Subject: [PATCH 09/43] Fixed setting defaults in User model of advanced app, see bb145f50672d35d62edede906255a8fe9a9c1f5f --- apps/advanced/common/models/User.php | 14 ++++++++++++++ apps/advanced/frontend/models/SignupForm.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/advanced/common/models/User.php b/apps/advanced/common/models/User.php index b3156a251b..6f43b28710 100644 --- a/apps/advanced/common/models/User.php +++ b/apps/advanced/common/models/User.php @@ -44,6 +44,20 @@ class User extends ActiveRecord implements IdentityInterface ]; } + /** + * @inheritdoc + */ + public function rules() + { + return [ + ['status', 'default', 'value' => self::STATUS_ACTIVE], + ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]], + + ['role', 'default', 'value' => self::ROLE_USER], + ['role', 'in', 'range' => [self::ROLE_USER]], + ]; + } + /** * @inheritdoc */ diff --git a/apps/advanced/frontend/models/SignupForm.php b/apps/advanced/frontend/models/SignupForm.php index 0597cbc664..17bcdeb51a 100644 --- a/apps/advanced/frontend/models/SignupForm.php +++ b/apps/advanced/frontend/models/SignupForm.php @@ -48,7 +48,7 @@ class SignupForm extends Model $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); - $user->save(false); + $user->save(); return $user; } From 4e5079abd81ed681273bb2880820b0518cf34176 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 4 May 2014 20:02:06 +0400 Subject: [PATCH 10/43] Fix #3327: "Unable to find debug data" when logging objects with circular references --- framework/CHANGELOG.md | 1 + framework/log/Target.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 20668b0131..568cd9c54e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -23,6 +23,7 @@ Yii Framework 2 Change Log - Bug #3236: Return value for DateTime->format('U') casted to double to allow correct date formatting (pgaultier) - Bug #3268: Fixed the bug that the schema name in a table name was not respected by `yii\db\mysql\Schema` (terazoid, qiangxue) - Bug #3311: Fixed the bug that `yii\di\Container::has()` did not return correct value (mgrechanik, qiangxue) +- Bug #3327: Fixed "Unable to find debug data" when logging objects with circular references (jarekkozak, samdark) - Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue) - Enh #2837: Error page now shows arguments in stack trace method calls (samdark) - Enh #2906: Added support for using conditional comments for js and css files registered through asset bundles and Html helper (exromany, qiangxue) diff --git a/framework/log/Target.php b/framework/log/Target.php index c355c159ff..950852f688 100644 --- a/framework/log/Target.php +++ b/framework/log/Target.php @@ -10,6 +10,7 @@ namespace yii\log; use Yii; use yii\base\Component; use yii\base\InvalidConfigException; +use yii\helpers\VarDumper; use yii\web\Request; /** @@ -115,7 +116,7 @@ abstract class Target extends Component $context = []; foreach ($this->logVars as $name) { if (!empty($GLOBALS[$name])) { - $context[] = "\${$name} = " . var_export($GLOBALS[$name], true); + $context[] = "\${$name} = " . VarDumper::dumpAsString($GLOBALS[$name]); } } From 82dbbce48133b9162e207ae27f5e3141dd9e4f49 Mon Sep 17 00:00:00 2001 From: Agrumas Date: Sun, 4 May 2014 20:01:30 +0300 Subject: [PATCH 11/43] Updated Lithuanian translation --- framework/messages/config.php | 2 +- framework/messages/lt/yii.php | 93 ++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/framework/messages/config.php b/framework/messages/config.php index 56bed56c3f..7bad25975b 100644 --- a/framework/messages/config.php +++ b/framework/messages/config.php @@ -7,7 +7,7 @@ return [ 'messagePath' => __DIR__, // array, required, list of language codes that the extracted messages // should be translated to. For example, ['zh-CN', 'de']. - 'languages' => ['ar', 'bg', 'da', 'de', 'el', 'es', 'fa-IR', 'fi', 'fr', 'hu', 'it', 'ja', 'kk', 'lv', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sr', 'sr-Latn', 'uk', 'vi', 'zh-CN'], + 'languages' => ['ar', 'bg', 'da', 'de', 'el', 'es', 'fa-IR', 'fi', 'fr', 'hu', 'it', 'ja', 'kk', 'lt', 'lv', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sr', 'sr-Latn', 'uk', 'vi', 'zh-CN'], // string, the name of the function for translating messages. // Defaults to 'Yii::t'. This is used as a mark to find the messages to be // translated. You may use a string for single function name or an array for diff --git a/framework/messages/lt/yii.php b/framework/messages/lt/yii.php index 3eb169404c..be28e28113 100644 --- a/framework/messages/lt/yii.php +++ b/framework/messages/lt/yii.php @@ -17,65 +17,92 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return array ( - 'View' => 'Peržiūrėti', + 'Are you sure to delete this item?' => '@@Ar tikrai norite ištrinti šį elementą?@@', + 'Only files with these mimeTypes are allowed: {mimeTypes}.' => '@@Leidžiama įkelti failus tik šių MIME tipų: {mimeTypes}.@@', '(not set)' => '(nenustatyta)', 'An internal server error occurred.' => 'Įvyko vidinė serverio klaida', - 'Are you sure to delete this item?' => 'Ar tikrai norite ištrinti šį elementą?', + 'Are you sure you want to delete this item?' => 'Ar tikrai norite ištrinti šį elementą?', 'Delete' => 'Ištrinti', 'Error' => 'Klaida', 'File upload failed.' => 'Nepavyko įkelti failo.', 'Home' => 'Pradžia', - 'Invalid data received for parameter "{param}".' => 'Gauti neteisingi duomenys į parametrą "{param}".', + 'Invalid data received for parameter "{param}".' => 'Gauti neteisingi "{param}" parametro duomenys.', 'Login Required' => 'Būtina prisijungti', - 'Missing required arguments: {params}' => 'Trūksta privalomo argumento: {params}', + 'Missing required arguments: {params}' => 'Trūksta privalomų argumentų: {params}', 'Missing required parameters: {params}' => 'Trūksta privalomų parametrų: {params}', 'No' => 'Ne', 'No help for unknown command "{command}".' => 'Nėra informacijos apie nežinomą "{command}" komandą.', 'No help for unknown sub-command "{command}".' => 'Nėra informacijos apie nežinomą "{command}" sub komandą', 'No results found.' => 'Nerasta rezultatų.', + 'Only files with these MIME types are allowed: {mimeTypes}.' => 'Leidžiama įkelti tik šių MIME tipų failus: {mimeTypes}.', 'Only files with these extensions are allowed: {extensions}.' => 'Leidžiama įkelti failus tik su šiais plėtiniais: {extensions}.', - 'Only files with these mimeTypes are allowed: {mimeTypes}.' => 'Leidžiama įkelti failus tik šių MIME tipų: {mimeTypes}.', 'Page not found.' => 'Puslapis nerastas.', 'Please fix the following errors:' => 'Prašytume ištaisyti nurodytas klaidas:', 'Please upload a file.' => 'Prašome įkelti failą.', 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => 'Rodomi rezultatai {begin, number}-{end, number}{totalCount, number}.', - 'The file "{file}" is not an image.' => 'Failas „{file}” nėra paveikslėlis.', - 'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}” yra per didelis. Dydis negali viršyti {limit, number} {limit, plural, one{baito} few{baitų} other{baitų}}.', - 'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}” yra per mažas. Izmēram ir jābūt vairāk par {limit, number} {limit, plural, one{baito} few{baitų} other{baitų}}.', - 'The format of {attribute} is invalid.' => 'Atributo „{attribute}” formatas yra netinkamas.', - 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per didelis. Aukštis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', - 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per didelis. Plotis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', - 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per mažas. Aukštis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', - 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}” yra per mažas. Plotis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', + 'The file "{file}" is not an image.' => 'Failas „{file}“ nėra paveikslėlis.', + 'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}“ yra per didelis. Dydis negali viršyti {limit, number} {limit, plural, one{baito} few{baitų} other{baitų}}.', + 'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'Failas „{file}“ yra per mažas. Dydis negali būti mažesnis už {limit, number} {limit, plural, one{baitą} few{baitus} other{baitų}}.', + 'The format of {attribute} is invalid.' => 'Atributo „{attribute}“ formatas yra netinkamas.', + 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}“ yra per didelis. Aukštis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', + 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}“ yra per didelis. Plotis negali viršyti {limit, number} {limit, plural, one{taško} few{taškų} other{taškų}}.', + 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}“ yra per mažas. Aukštis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', + 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'Paveikslėlis „{file}“ yra per mažas. Plotis turi viršyti {limit, number} {limit, plural, one{tašką} few{taškus} other{taškų}}.', + 'The requested view "{name}" was not found.' => 'Nerastas „{name}“ rodinys', 'The verification code is incorrect.' => 'Neteisingas patikrinimo kodas.', 'Total {count, number} {count, plural, one{item} other{items}}.' => 'Iš viso {count, number} {count, plural, one{elementas} few{elementai} other{elementų}}.', 'Unable to verify your data submission.' => 'Neįmanoma patikrinti jūsų siunčiamų duomenų.', 'Unknown command "{command}".' => 'Nežinoma komanda "{command}".', 'Unknown option: --{name}' => 'Nežinomas pasirinkimas: --{name}', 'Update' => 'Atnaujinti', + 'View' => 'Peržiūrėti', 'Yes' => 'Taip', 'You are not allowed to perform this action.' => 'Jums neleidžiama atlikti šio veiksmo.', 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Leidžiama įkelti ne daugiau nei {limit, number} {limit, plural, one{failą} few{failus} other{failų}}.', + 'in {delta, plural, =1{a day} other{# days}}' => 'po {delta, plural, =1{dienos} one{# dienos} other{# dienų}}', + 'in {delta, plural, =1{a minute} other{# minutes}}' => 'po {delta, plural, =1{minutės} one{# minutės} other{# minučių}}', + 'in {delta, plural, =1{a month} other{# months}}' => 'po {delta, plural, =1{mėnesio} one{# mėnesio} other{# mėnesių}}', + 'in {delta, plural, =1{a second} other{# seconds}}' => 'po {delta, plural, =1{sekundės} one{# sekundės} other{# sekundžių}}', + 'in {delta, plural, =1{a year} other{# years}}' => 'po {delta, plural, =1{metų} other{# metų}}', + 'in {delta, plural, =1{an hour} other{# hours}}' => 'po {delta, plural, =1{valandos} one{# valandos} other{# valandų}}', 'the input value' => 'įvesties reikšmė', - '{attribute} "{value}" has already been taken.' => '{attribute} reikšmė „{value}” jau naudojama.', - '{attribute} cannot be blank.' => '„{attribute}” negali būti tuščias.', + '{attribute} "{value}" has already been taken.' => '{attribute} reikšmė „{value}“ jau naudojama.', + '{attribute} cannot be blank.' => '„{attribute}“ negali būti tuščias.', '{attribute} is invalid.' => '„{attribute}“ reikšmė netinkama.', - '{attribute} is not a valid URL.' => '„{attribute}” įvestas netinkamas URL.', - '{attribute} is not a valid email address.' => '„{attribute}” įvestas netinkamas el. pašto adresas.', - '{attribute} must be "{requiredValue}".' => '„{attribute}” privalo būti „{requiredValue}”.', - '{attribute} must be a number.' => '„{attribute}” privalo būti skaičius.', - '{attribute} must be a string.' => '„{attribute}” privalo būti eilutė.', - '{attribute} must be an integer.' => '„{attribute}” privalo būti sveikas skaičius.', - '{attribute} must be either "{true}" or "{false}".' => '„{attribute}” privalo būti „{true}” arba „{false}”.', - '{attribute} must be greater than "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti didesnė nei „{compareValue}”.', - '{attribute} must be greater than or equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti didesnė arba lygi „{compareValue}”.', - '{attribute} must be less than "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti mažesnė nei „{compareValue}”.', - '{attribute} must be less than or equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė privalo būti mažesnė arba lygi „{compareValue}”.', - '{attribute} must be no greater than {max}.' => 'Laukelio „{attribute}” reikšmė privalo būti ne didesnė nei {max}.', - '{attribute} must be no less than {min}.' => 'Laukelio „{attribute}” reikšmė privalo būti ne mažesnė nei {min}.', - '{attribute} must be repeated exactly.' => 'Laukelio „{attribute}” reikšmė privalo būti pakartota tiksliai.', - '{attribute} must not be equal to "{compareValue}".' => 'Laukelio „{attribute}” reikšmė negali būti lygi „{compareValue}”.', - '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti mažiausiai {min, number} {min, plural, one{ženklas} few{ženklai} other{ženklų}}.', - '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti daugiausiai {max, number} {max, plural, one{ženklas} few{ženklai} other{ženklų}}.', - '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}” reikšmę privalo sudaryti {length, number} {length, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{attribute} is not a valid URL.' => '„{attribute}“ įvestas netinkamas URL.', + '{attribute} is not a valid email address.' => '„{attribute}“ įvestas netinkamas el. pašto adresas.', + '{attribute} must be "{requiredValue}".' => '„{attribute}“ privalo būti „{requiredValue}“.', + '{attribute} must be a number.' => '„{attribute}“ privalo būti skaičius.', + '{attribute} must be a string.' => '„{attribute}“ privalo būti eilutė.', + '{attribute} must be an integer.' => '„{attribute}“ privalo būti sveikas skaičius.', + '{attribute} must be either "{true}" or "{false}".' => '„{attribute}“ privalo būti „{true}“ arba „{false}“.', + '{attribute} must be greater than "{compareValue}".' => 'Laukelio „{attribute}“ reikšmė privalo būti didesnė nei „{compareValue}“.', + '{attribute} must be greater than or equal to "{compareValue}".' => 'Laukelio „{attribute}“ reikšmė privalo būti didesnė arba lygi „{compareValue}“.', + '{attribute} must be less than "{compareValue}".' => 'Laukelio „{attribute}“ reikšmė privalo būti mažesnė nei „{compareValue}“.', + '{attribute} must be less than or equal to "{compareValue}".' => 'Laukelio „{attribute}“ reikšmė privalo būti mažesnė arba lygi „{compareValue}“.', + '{attribute} must be no greater than {max}.' => 'Laukelio „{attribute}“ reikšmė privalo būti ne didesnė nei {max}.', + '{attribute} must be no less than {min}.' => 'Laukelio „{attribute}“ reikšmė privalo būti ne mažesnė nei {min}.', + '{attribute} must be repeated exactly.' => 'Laukelio „{attribute}“ reikšmė privalo būti pakartota tiksliai.', + '{attribute} must not be equal to "{compareValue}".' => 'Laukelio „{attribute}“ reikšmė negali būti lygi „{compareValue}“.', + '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}“ reikšmę privalo sudaryti mažiausiai {min, number} {min, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}“ reikšmę privalo sudaryti daugiausiai {max, number} {max, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => 'Laukelio „{attribute}“ reikšmę privalo sudaryti {length, number} {length, plural, one{ženklas} few{ženklai} other{ženklų}}.', + '{delta, plural, =1{a day} other{# days}} ago' => 'prieš {delta, plural, =1{dieną} one{# dieną} few{# dienas} other{# dienų}}', + '{delta, plural, =1{a minute} other{# minutes}} ago' => 'prieš {delta, plural, =1{minutę} one{# minutę} few{# minutes} other{# minučių}}', + '{delta, plural, =1{a month} other{# months}} ago' => 'prieš {delta, plural, =1{mėnesį} one{# mėnesį} few{# mėnesius} other{# mėnesių}}', + '{delta, plural, =1{a second} other{# seconds}} ago' => 'prieš {delta, plural, =1{sekundę} one{# sekundę} few{# sekundes} other{# sekundžių}}', + '{delta, plural, =1{a year} other{# years}} ago' => 'prieš {delta, plural, =1{metus} one{# metus} few{# metus} other{# metų}}', + '{delta, plural, =1{an hour} other{# hours}} ago' => 'prieš {delta, plural, =1{valandą} one{# valandą} few{# valandas} other{# valandų}}', + '{n, plural, =1{# byte} other{# bytes}}' => '{n, number} {n, plural, one{baitas} few{baitai} other{baitų}}', + '{n, plural, =1{# gigabyte} other{# gigabytes}}' => '{n, number} giga{n, plural, one{baitas} few{baitai} other{baitų}}', + '{n, plural, =1{# kilobyte} other{# kilobytes}}' => '{n, number} kilo{n, plural, one{baitas} few{baitai} other{baitų}}', + '{n, plural, =1{# megabyte} other{# megabytes}}' => '{n, number} mega{n, plural, one{baitas} few{baitai} other{baitų}}', + '{n, plural, =1{# petabyte} other{# petabytes}}' => '{n, number} peta{n, plural, one{baitas} few{baitai} other{baitų}}', + '{n, plural, =1{# terabyte} other{# terabytes}}' => '{n, number} tera{n, plural, one{baitas} few{baitai} other{baitų}}', + '{n} B' => '{n} B', + '{n} GB' => '{n} GB', + '{n} KB' => '{n} KB', + '{n} MB' => '{n} MB', + '{n} PB' => '{n} PB', + '{n} TB' => '{n} TB', ); From 135b944c14add98ddf3cda11d89772f33d82e76f Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 4 May 2014 13:12:20 -0400 Subject: [PATCH 12/43] Finished guide about DI container and service locator. --- docs/guide/concept-di-container.md | 160 +++++++++++++++++----- docs/guide/concept-service-locator.md | 35 +++-- tests/unit/framework/di/ContainerTest.php | 9 ++ 3 files changed, 154 insertions(+), 50 deletions(-) diff --git a/docs/guide/concept-di-container.md b/docs/guide/concept-di-container.md index b175f5f4c1..8c03e6194c 100644 --- a/docs/guide/concept-di-container.md +++ b/docs/guide/concept-di-container.md @@ -1,30 +1,104 @@ Dependency Injection Container ============================== -Both service locator and dependency injection are popular design patterns that allow building software -in a loosely-coupled fashion. Yii uses service locator and dependency injection extensively, -even though you may not be aware of them. In this tutorial, we will explore their implementation -and support to help you write code more consciously. We also highly recommend you to read -[Martin's article](http://martinfowler.com/articles/injection.html) to get a deeper understanding of -service locator and dependency injection. - A dependency injection (DI) container is an object that knows how to instantiate and configure objects and all their dependent objects. [Martin's article](http://martinfowler.com/articles/injection.html) has well explained why DI container is useful. Here we will mainly explain the usage of the DI container provided by Yii. + + +Dependency Injection +-------------------- + Yii provides the DI container feature through the class [[yii\di\Container]]. It supports the following kinds of dependency injection: * Constructor injection; -* Setter injection; +* Setter and property injection; * PHP callable injection. -### Registering Dependencies + +### Constructor Injection + +The DI container supports constructor injection with the help of type hints for constructor parameters. +The type hints tell the container which classes or interfaces are dependent when it is used to create a new object. +The container will try to get the instances of the dependent classes or interfaces and then inject them +into the new object through the constructor. For example, + +```php +class Foo +{ + public function __construct(Bar $bar) + { + } +} + +$foo = $container->get('Foo'); +// which is equivalent to the following: +$bar = new Bar; +$foo = new Foo($bar); +``` + + + +### Setter and Property Injection + +Setter and property injection is supported through [configurations](concept-configurations.md). +When registering a dependency or when creating a new object, you can provide a configuration which +will be used by the container to inject the dependencies through the corresponding setters or properties. +For example, + +```php +use yii\base\Object; + +class Foo extends Object +{ + public $bar; + + private $_qux; + + public function getQux() + { + return $this->_qux; + } + + public function setQux(Qux $qux) + { + $this->_qux = $qux; + } +} + +$container->get('Foo', [], [ + 'bar' => $container->get('Bar'), + 'qux' => $container->get('Qux'), +]); +``` + + + +### PHP Callable Injection + +In this case, the container will use a registered PHP callable to build new instances of a class. +The callable is responsible to resolve the dependencies and inject them appropriately to the newly +created objects. For example, + +```php +$container->set('Foo', function () { + return new Foo(new Bar); +}); + +$foo = $container->get('Foo'); +``` + + + +Registering Dependencies +------------------------ You can use [[yii\di\Container::set()]] to register dependencies. The registration requires a dependency name -as well as a dependency definition. The name can be a class name, an interface name, or an alias name; -and the definition can be a class name, a configuration array, or a PHP callable. +as well as a dependency definition. A dependency name can be a class name, an interface name, or an alias name; +and a dependency definition can be a class name, a configuration array, or a PHP callable. ```php $container = new \yii\di\Container; @@ -61,10 +135,14 @@ $container->set('db', [ ]); // register a PHP callable -// The callable will be executed when $container->get('db') is called +// The callable will be executed each time when $container->get('db') is called $container->set('db', function ($container, $params, $config) { return new \yii\db\Connection($config); }); + +// register a component instance +// $container->get('pageCache') will return the same instance each time it is called +$container->set('pageCache', new FileCache); ``` > Tip: If a dependency name is the same as the corresponding dependency definition, you do not @@ -84,28 +162,31 @@ $container->setSingleton('yii\db\Connection', [ ``` -### Resolving Dependencies + +Resolving Dependencies +---------------------- Once you have registered dependencies, you can use the DI container to create new objects, and the container will automatically resolve dependencies by instantiating them and injecting them into the newly created objects. The dependency resolution is recursive, meaning that if a dependency has other dependencies, those dependencies will also be resolved automatically. -You use [[yii\di\Container::get()]] to create new objects. The method takes a class name or -a dependency name (class name, interface name or alias name) that you previously registered -via `set()` or `setSingleton()`. You may optionally provide a list of class constructor parameters -and a list of name-value pairs to configure the newly created object. For example, +You can use [[yii\di\Container::get()]] to create new objects. The method takes a dependency name, +which can be a class name, an interface name or an alias name. The dependency name may or may +not be registered via `set()` or `setSingleton()`. You may optionally provide a list of class +constructor parameters and a [configuration](concept-configurations.md) to configure the newly created object. +For example, ```php -// equivalent to: $map = new \app\components\GoogleMap($apiKey); -$map = $container->get('app\components\GoogleMap', [$apiKey]); - // "db" is a previously registered alias name $db = $container->get('db'); + +// equivalent to: $engine = new \app\components\SearchEngine($apiKey, ['type' => 1]); +$engine = $container->get('app\components\SearchEngine', [$apiKey], ['type' => 1]); ``` Behind the scene, the DI container does much more work than just creating a new object. -The container will inspect the class constructor to find out dependent class or interface names +The container will first inspect the class constructor to find out dependent class or interface names and then automatically resolve those dependencies recursively. The following code shows a more sophisticated example. The `UserLister` class depends on an object implementing @@ -114,7 +195,6 @@ a `Connection` object. All these dependencies are declared through type hinting With property dependency registration, the DI container is able to resolve these dependencies automatically and creates a new `UserLister` instance with a simple call of `get('userLister')`. - ```php namespace app\models; @@ -172,11 +252,13 @@ $lister = new UserLister($finder); ``` -### Practical Usage + +Practical Usages +---------------- -Yii creates a DI container when you include the `yii.php` file in your application's entry script. -The DI container is accessible via [[Yii::$container]]. When you call [[Yii::createObject()]], the method -will actually call the container's [[yii\di\Container::get()|get()]] method to create a new object. +Yii creates a DI container when you include the `Yii.php` file in the [entry script](structure-entry-scripts.md) +of your application. The DI container is accessible via [[Yii::$container]]. When you call [[Yii::createObject()]], +the method will actually call the container's [[yii\di\Container::get()|get()]] method to create a new object. As aforementioned, the DI container will automatically resolve the dependencies (if any) and inject them into the newly created object. Because Yii uses [[Yii::createObject()]] in most of its core code to create new objects, this means you can customize the objects globally by dealing with [[Yii::$container]]. @@ -188,13 +270,13 @@ For example, you can customize globally the default number of pagination buttons ``` Now if you use the widget in a view with the following code, the `maxButtonCount` property will be initialized -as 5 instead of 10 as defined in the class. +as 5 instead of the default value 10 as defined in the class. ```php echo \yii\widgets\LinkPager::widget(); ``` -You can still override the value set via DI container: +You can still override the value set via DI container, though: ```php echo \yii\widgets\LinkPager::widget(['maxButtonCount' => 20]); @@ -233,13 +315,29 @@ Now if you access the controller again, an instance of `app\components\BookingSe created and injected as the 3rd parameter to the controller's constructor. -### When to Register Dependencies + +When to Register Dependencies +----------------------------- Because dependencies are needed when new objects are being created, their registration should be done as early as possible. The followings are the recommended practices: * If you are the developer of an application, you can register dependencies in your - application's entry script or in a script that is included by the entry script. -* If you are the developer of a redistributable extension, you can register dependencies + application's [entry script](structure-entry-scripts.md) or in a script that is included by the entry script. +* If you are the developer of a redistributable [extension](structure-extensions.md), you can register dependencies in the bootstrap class of the extension. + + +Summary +------- + +Both dependency injection and [service locator](concept-service-locator.md) are popular design patterns +that allow building software in a loosely-coupled and more testable fashion. We highly recommend you to read +[Martin's article](http://martinfowler.com/articles/injection.html) to get a deeper understanding of +dependency injection and service locator. + +Yii implements its [service locator](concept-service-locator.md) on top of the dependency injection (DI) container. +When a service locator is trying to create a new object instance, it will forward the call to the DI container. +The latter will resolve the dependencies automatically as described above. + diff --git a/docs/guide/concept-service-locator.md b/docs/guide/concept-service-locator.md index 4350981acb..374f0c5587 100644 --- a/docs/guide/concept-service-locator.md +++ b/docs/guide/concept-service-locator.md @@ -1,23 +1,15 @@ Service Locator =============== -> Note: This chapter needs cleanup. - -Both service locator and dependency injection are popular design patterns that allow building software -in a loosely-coupled fashion. Yii uses service locator and dependency injection extensively, -even though you may not be aware of them. In this tutorial, we will explore their implementation -and support to help you write code more consciously. We also highly recommend you to read -[Martin's article](http://martinfowler.com/articles/injection.html) to get a deeper understanding of -service locator and dependency injection. - A service locator is an object that knows how to provide all sorts of services (or components) that an application might need. Within a service locator, each component has only a single instance which is uniquely identified by an ID. -You use the ID to retrieve a component from the service locator. In Yii, a service locator is simply an instance -of [[yii\di\ServiceLocator]] or its child class. +You use the ID to retrieve a component from the service locator. + +In Yii, a service locator is simply an instance of [[yii\di\ServiceLocator]] or its child class. The most commonly used service locator in Yii is the *application* object which can be accessed through -`\Yii::$app`. The services it provides are called *application components*, such as `request`, `response`, -`urlManager`. You may configure these components or replace them with your own implementations easily +`\Yii::$app`. The services it provides are called *application components*, such as the `request`, `response`, +`urlManager` components. You may configure these components or even replace them with your own implementations easily through functionality provided the service locator. Besides the application object, each module object is also a service locator. @@ -26,7 +18,10 @@ To use a service locator, the first step is to register components. A component via [[yii\di\ServiceLocator::set()]]. The following code shows different ways of registering components: ```php -$locator = new \yii\di\ServiceLocator; +use yii\di\ServiceLocator; +use yii\caching\FileCache; + +$locator = new ServiceLocator; // register "cache" using a class name that can be used to create a component $locator->set('cache', 'yii\caching\ApcCache'); @@ -43,6 +38,9 @@ $locator->set('db', [ $locator->set('search', function () { return new app\components\SolrService; }); + +// register "pageCache" using a component +$locator->set('pageCache', new FileCache); ``` Once a component is registered, you can access it using its ID in one of the following two ways: @@ -62,11 +60,10 @@ You may use [[yii\di\ServiceLocator::has()]] to check if a component ID has alre If you call [[yii\di\ServiceLocator::get()]] with an invalid ID, an exception will be thrown. -Because service locators are often being configured using configuration arrays, a method named -[[yii\di\ServiceLocator::setComponents()]] is provided to allow registering components in configuration arrays. -The method is a setter which defines a writable property `components` that can be configured. -The following code shows a configuration array that can be used to configure an application and register -the "db", "cache" and "search" components: +Because service locators are often being created with [configurations](concept-configurations.md), +a writable property named [[yii\di\ServiceLocator::setComponents()|components]] is provided so that +you can configure it and register multiple components at once. The following code shows a configuration array +that can be used to configure an application and register the "db", "cache" and "search" components: ```php return [ diff --git a/tests/unit/framework/di/ContainerTest.php b/tests/unit/framework/di/ContainerTest.php index ab2447dcb0..4098ebc71a 100644 --- a/tests/unit/framework/di/ContainerTest.php +++ b/tests/unit/framework/di/ContainerTest.php @@ -36,6 +36,8 @@ class ContainerTest extends TestCase $this->assertTrue($foo instanceof $Foo); $this->assertTrue($foo->bar instanceof $Bar); $this->assertTrue($foo->bar->qux instanceof $Qux); + $foo2 = $container->get($Foo); + $this->assertFalse($foo === $foo2); // full wiring $container = new Container; @@ -80,5 +82,12 @@ class ContainerTest extends TestCase $this->assertTrue($foo instanceof $Foo); $this->assertTrue($foo->bar instanceof $Bar); $this->assertTrue($foo->bar->qux instanceof $Qux); + + // wiring by closure + $container = new Container; + $container->set('qux', new Qux); + $qux1 = $container->get('qux'); + $qux2 = $container->get('qux'); + $this->assertTrue($qux1 === $qux2); } } From c19e76e09ddddbe34a925ca0dc8fedc0c4d2bd39 Mon Sep 17 00:00:00 2001 From: Agrumas Date: Sun, 4 May 2014 20:45:46 +0300 Subject: [PATCH 13/43] Lithuanian translation cleanup. [skip ci] --- framework/messages/lt/yii.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/framework/messages/lt/yii.php b/framework/messages/lt/yii.php index be28e28113..b33f9877bb 100644 --- a/framework/messages/lt/yii.php +++ b/framework/messages/lt/yii.php @@ -16,9 +16,7 @@ * * NOTE: this file must be saved in UTF-8 encoding. */ -return array ( - 'Are you sure to delete this item?' => '@@Ar tikrai norite ištrinti šį elementą?@@', - 'Only files with these mimeTypes are allowed: {mimeTypes}.' => '@@Leidžiama įkelti failus tik šių MIME tipų: {mimeTypes}.@@', +return [ '(not set)' => '(nenustatyta)', 'An internal server error occurred.' => 'Įvyko vidinė serverio klaida', 'Are you sure you want to delete this item?' => 'Ar tikrai norite ištrinti šį elementą?', @@ -105,4 +103,4 @@ return array ( '{n} MB' => '{n} MB', '{n} PB' => '{n} PB', '{n} TB' => '{n} TB', -); +]; From 981f895c42cb6f97a355d8fbbdb16a3ecca51935 Mon Sep 17 00:00:00 2001 From: tsvetann Date: Sun, 4 May 2014 20:26:47 +0200 Subject: [PATCH 14/43] Update concept-service-locator.md --- docs/guide/concept-service-locator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/concept-service-locator.md b/docs/guide/concept-service-locator.md index 374f0c5587..cc9c3e1e0e 100644 --- a/docs/guide/concept-service-locator.md +++ b/docs/guide/concept-service-locator.md @@ -10,7 +10,7 @@ In Yii, a service locator is simply an instance of [[yii\di\ServiceLocator]] or The most commonly used service locator in Yii is the *application* object which can be accessed through `\Yii::$app`. The services it provides are called *application components*, such as the `request`, `response`, `urlManager` components. You may configure these components or even replace them with your own implementations easily -through functionality provided the service locator. +through functionality provided by the service locator. Besides the application object, each module object is also a service locator. From f8fefb009f135266624f3f174f729e4eb3b2168b Mon Sep 17 00:00:00 2001 From: tsvetann Date: Sun, 4 May 2014 21:11:16 +0200 Subject: [PATCH 15/43] Update Generator.php To comply with the docs RE namespace usage: https://github.com/yiisoft/yii2/blob/master/docs/guide/extend-creating-extensions.md --- extensions/gii/generators/extension/Generator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/gii/generators/extension/Generator.php b/extensions/gii/generators/extension/Generator.php index f6a1c9d5a6..33ce0470e5 100644 --- a/extensions/gii/generators/extension/Generator.php +++ b/extensions/gii/generators/extension/Generator.php @@ -112,7 +112,7 @@ class Generator extends \yii\gii\Generator return [ 'vendorName' => 'This refers to the name of the publisher, your GitHub user name is usually a good choice, eg. myself.', 'packageName' => 'This is the name of the extension on packagist, eg. yii2-foobar.', - 'namespace' => 'PSR-4, eg. myself\foobar\ This will be added to your autoloading by composer. Do not use yii or yii2 in the namespace.', + 'namespace' => 'PSR-4, eg. myself\foobar\ This will be added to your autoloading by composer. Do not use yii, yii2 or yiisoft in the namespace.', 'keywords' => 'Comma separated keywords for this extension.', 'outputPath' => 'The temporary location of the generated files.', 'title' => 'A more descriptive name of your application for the README file.', From 5196ba372f4eb2691f02847a3256bb99ae59a344 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 4 May 2014 23:44:16 +0400 Subject: [PATCH 16/43] Replaces tabs to spaces in example code --- extensions/twig/README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/extensions/twig/README.md b/extensions/twig/README.md index e7afabee03..94b404bcf6 100644 --- a/extensions/twig/README.md +++ b/extensions/twig/README.md @@ -7,19 +7,19 @@ To use this extension, simply add the following code in your application configu ```php return [ - //.... - 'components' => [ - 'view' => [ - 'renderers' => [ - 'twig' => [ - 'class' => 'yii\twig\ViewRenderer', - //'cachePath' => '@runtime/Twig/cache', - //'options' => [], /* Array of twig options */ - // ... see ViewRenderer for more options - ], - ], - ], - ], + //.... + 'components' => [ + 'view' => [ + 'renderers' => [ + 'twig' => [ + 'class' => 'yii\twig\ViewRenderer', + //'cachePath' => '@runtime/Twig/cache', + //'options' => [], /* Array of twig options */ + // ... see ViewRenderer for more options + ], + ], + ], + ], ]; ``` From 539b74d172cc26f460a88c4998aeda7df168ff46 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 00:52:45 +0400 Subject: [PATCH 17/43] Added note about disabling cache to twig extension readme --- extensions/twig/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/twig/README.md b/extensions/twig/README.md index 94b404bcf6..cf311a9c7b 100644 --- a/extensions/twig/README.md +++ b/extensions/twig/README.md @@ -13,6 +13,7 @@ return [ 'renderers' => [ 'twig' => [ 'class' => 'yii\twig\ViewRenderer', + // set cachePath to false in order to disable template caching //'cachePath' => '@runtime/Twig/cache', //'options' => [], /* Array of twig options */ // ... see ViewRenderer for more options From 7f6fc39861e3497755d342853ab20bbc2d4c45d6 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 01:13:20 +0400 Subject: [PATCH 18/43] Fixes #1799: Added form_begin, form_end to twig extension --- docs/guide/tutorial-template-engines.md | 28 ++++++++++++------------- extensions/twig/CHANGELOG.md | 1 + extensions/twig/ViewRenderer.php | 14 ++++++++----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/docs/guide/tutorial-template-engines.md b/docs/guide/tutorial-template-engines.md index 29aca04f4d..bcf3b2407b 100644 --- a/docs/guide/tutorial-template-engines.md +++ b/docs/guide/tutorial-template-engines.md @@ -52,26 +52,26 @@ or `$this->renderPartial()` controller calls: echo $this->render('renderer.twig', ['username' => 'Alex']); ``` -### Additional syntax - -Yii adds some extra syntax constructs additionally to standard Twig ones. - - -### - -{{registerAssetBundle('AppAsset')}} - Registers asset bundle of a given name - - ### Forms +There are two form helper functions `form_begin` and `form_end` to make using forms more convenient: + ``` -{% set form = form_begin({ ... }) %} -{{ form.field(...) }} -{% form.end() %} +{% set form = form_begin({ + 'id' : 'login-form', + 'options' : {'class' : 'form-horizontal'}, +}) %} + {{ form.field(model, 'username') | raw }} + {{ form.field(model, 'password').passwordInput() | raw }} + +

+ +
+{{ form_end() }} ``` -#### Getting URL for a route +### Getting URL for a route There are two functions you can use for URLs: diff --git a/extensions/twig/CHANGELOG.md b/extensions/twig/CHANGELOG.md index 1ec55ccf01..6f989851e4 100644 --- a/extensions/twig/CHANGELOG.md +++ b/extensions/twig/CHANGELOG.md @@ -5,6 +5,7 @@ Yii Framework 2 twig extension Change Log -------------------------- - Bug #2925: Fixed throwing exception when accessing AR property with null value (samdark) +- Enh #1799: Added `form_begin`, `form_end` to twig extension (samdark) 2.0.0-beta April 13, 2014 diff --git a/extensions/twig/ViewRenderer.php b/extensions/twig/ViewRenderer.php index 2f373a0309..0d6ff9c974 100644 --- a/extensions/twig/ViewRenderer.php +++ b/extensions/twig/ViewRenderer.php @@ -11,6 +11,7 @@ use Yii; use yii\base\View; use yii\base\ViewRenderer as BaseViewRenderer; use yii\helpers\Url; +use yii\widgets\ActiveForm; /** * TwigViewRenderer allows you to use Twig templates in views. @@ -115,11 +116,6 @@ class ViewRenderer extends BaseViewRenderer $this->setLexerOptions($this->lexerOptions); } -// $this->addFunctions([ -// 'rot13' => 'str_rot13', -// 'jsonEncode' => '\yii\helpers\Json::encode', -// ]); - // Adding global 'void' function (usage: {{void(App.clientScript.registerScriptFile(...))}}) $this->twig->addFunction('void', new \Twig_Function_Function(function ($argument) { })); @@ -132,6 +128,14 @@ class ViewRenderer extends BaseViewRenderer return Url::to(array_merge([$path], $args), true); })); + $this->twig->addFunction('form_begin', new \Twig_Function_Function(function ($args = []) { + return ActiveForm::begin($args); + })); + + $this->twig->addFunction('form_end', new \Twig_Function_Function(function () { + ActiveForm::end(); + })); + $this->twig->addGlobal('app', \Yii::$app); } From bb4073c9afdf417e847432b1fad51e32a27a11eb Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 01:37:50 +0400 Subject: [PATCH 19/43] Fixes #1838: documented Yii-specific syntax for Twig extension --- docs/guide/tutorial-template-engines.md | 78 ++++++++++++++++++++----- 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/docs/guide/tutorial-template-engines.md b/docs/guide/tutorial-template-engines.md index bcf3b2407b..6349b782ab 100644 --- a/docs/guide/tutorial-template-engines.md +++ b/docs/guide/tutorial-template-engines.md @@ -44,15 +44,44 @@ That code would be added to the `require` section of `composer.json`. After maki Twig ---- -To use Twig, you need to create templates in files that have the `.twig` extension (or use another file extension but configure the component accordingly). -Unlike standard view files, when using Twig you must include the extension in your `$this->render()` -or `$this->renderPartial()` controller calls: +To use Twig, you need to create templates in files that have the `.twig` extension (or use another file extension but +configure the component accordingly). Unlike standard view files, when using Twig you must include the extension +in your `$this->render()` or `$this->renderPartial()` controller calls: ```php echo $this->render('renderer.twig', ['username' => 'Alex']); ``` -### Forms +### Template syntax + +The best resource to learn Twig basics is its official documentation you can find at +[twig.sensiolabs.org](http://twig.sensiolabs.org/documentation). Additionally there are Yii-specific addtions +described below. + +#### Method and function calls + +If you need result you can call a method or a function using the following syntax: + +``` +{% set result = my_function({'a' : 'b'}) %} +{% set result = myObject.my_function({'a' : 'b'}) %} +``` + +If you need to echo result instead of assigning it to a variable: + +``` +{{ my_function({'a' : 'b'}) }} +{{ myObject.my_function({'a' : 'b'}) }} +``` + +In case you don't need result you shoud use `void` wrapper: + +``` +{{ void(my_function({'a' : 'b'})) }} +{{ void(myObject.my_function({'a' : 'b'})} }} +``` + +#### Forms There are two form helper functions `form_begin` and `form_end` to make using forms more convenient: @@ -71,9 +100,9 @@ There are two form helper functions `form_begin` and `form_end` to make using fo ``` -### Getting URL for a route +#### URLs -There are two functions you can use for URLs: +There are two functions you can use for building URLs: ```php {{ post.title }} @@ -82,17 +111,22 @@ There are two functions you can use for URLs: `path` generates relative URL while `url` generates absolute one. Internally both are using [[\yii\helpers\Url]]. -### Additional variables +#### Additional variables -Within Twig templates, you can also make use of these variables: +Within Twig templates the following variables are always defined: - `app`, which equates to `\Yii::$app` - `this`, which equates to the current `View` object -### Globals +### Additional configuration -You can add global helpers or values via the application configuration's `globals` variable. You can define both Yii helpers and your own -variables there: +Yii Twig extension allows you to define your own syntax and bring regular helper classes into templates. Let's review +configuration options. + +#### Globals + +You can add global helpers or values via the application configuration's `globals` variable. You can define both Yii +helpers and your own variables there: ```php 'globals' => [ @@ -107,7 +141,25 @@ Once configured, in your template you can use the globals in the following way: Hello, {{name}}! {{ html.a('Please login', 'site/login') | raw }}. ``` -### Additional filters +#### Functions + +You can define additional functions like the following: + +```php +'functions' => [ + 'rot13' => 'str_rot13', + 'truncate' => '\yii\helpers\StringHelper::truncate', +], +``` + +In template they could be used like the following: + +``` +`{{ rot13('test') }}` +`{{ truncate(post.text, 100) }}` +``` + +#### Filters Additional filters may be added via the application configuration's `filters` option: @@ -117,7 +169,7 @@ Additional filters may be added via the application configuration's `filters` op ], ``` -Then in the template you can use: +Then in the template you can apply filter using the following syntax: ``` {{ model|jsonEncode }} From c9635dd9b10d81840111869339282fe0db1d9e30 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 01:55:45 +0400 Subject: [PATCH 20/43] Added class example to Twig extension docs --- docs/guide/tutorial-template-engines.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/guide/tutorial-template-engines.md b/docs/guide/tutorial-template-engines.md index 6349b782ab..56a4168a0d 100644 --- a/docs/guide/tutorial-template-engines.md +++ b/docs/guide/tutorial-template-engines.md @@ -132,6 +132,7 @@ helpers and your own variables there: 'globals' => [ 'html' => '\yii\helpers\Html', 'name' => 'Carsten', + 'GridView' => '\yii\grid\GridView', ], ``` @@ -139,6 +140,8 @@ Once configured, in your template you can use the globals in the following way: ``` Hello, {{name}}! {{ html.a('Please login', 'site/login') | raw }}. + +{{ GridView.widget({'dataProvider' : provider}) | raw }} ``` #### Functions From 8b4dbff56c45b5058500de19cbf9d3654e0971c7 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 02:13:56 +0400 Subject: [PATCH 21/43] Closes #3281: removed strict rule about using "new" from code style --- docs/internals/core-code-style.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/internals/core-code-style.md b/docs/internals/core-code-style.md index fae7fff1d4..c67302a114 100644 --- a/docs/internals/core-code-style.md +++ b/docs/internals/core-code-style.md @@ -139,7 +139,6 @@ class Foo ### 4.5 Constructors - `__construct` should be used instead of PHP 4 style constructors. -- When instantiating class it should be `new MyClass();` instead of `new MyClass;`. ## 5 PHP From c8da5372c4eb4010d2bc3df498164beca97bd2b9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 02:29:09 +0400 Subject: [PATCH 22/43] Fixes #3211 --- docs/guide/security-authentication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/security-authentication.md b/docs/guide/security-authentication.md index 91217a59dc..64d03f8687 100644 --- a/docs/guide/security-authentication.md +++ b/docs/guide/security-authentication.md @@ -8,7 +8,7 @@ Authentication is the act of verifying who a user is, and is the basis of the lo In Yii, this entire process is performed semi-automatically, leaving the developer to merely implement [[yii\web\IdentityInterface]], the most important class in the authentication system. Typically, implementation of `IdentityInterface` is accomplished using the `User` model. You can find a fully featured example of authentication in the -[advanced application template](installation.md). Below, only the interface methods are listed: +[advanced application template](tutorial-advanced-app.md). Below, only the interface methods are listed: ```php class User extends ActiveRecord implements IdentityInterface From 3ac7240a7477809647dc4931c6bf7605dfca1d24 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 5 May 2014 02:54:46 +0400 Subject: [PATCH 23/43] Fixes #2344 --- docs/guide/db-dao.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/db-dao.md b/docs/guide/db-dao.md index b7f1940367..d529b290da 100644 --- a/docs/guide/db-dao.md +++ b/docs/guide/db-dao.md @@ -182,7 +182,7 @@ Quoting table and column names Most of the time you would use the following syntax for quoting table and column names: ```php -$sql = "SELECT COUNT([[$column]]) FROM {{$table}}"; +$sql = "SELECT COUNT([[$column]]) FROM {{table}}"; $rowCount = $connection->createCommand($sql)->queryScalar(); ``` @@ -192,7 +192,7 @@ quoted table name. For table names there's a special variant `{{%Y}}` that allows you to automatically appending table prefix if it is set: ```php -$sql = "SELECT COUNT([[$column]]) FROM {{%$table}}"; +$sql = "SELECT COUNT([[$column]]) FROM {{%table}}"; $rowCount = $connection->createCommand($sql)->queryScalar(); ``` From 5ea81a91c9b28727de2cf291ac4cf6a6c7a12056 Mon Sep 17 00:00:00 2001 From: Yeung Song Date: Mon, 5 May 2014 16:33:08 +0800 Subject: [PATCH 24/43] Fixed document for multisort in BaseArrayHelper Fixed --- framework/helpers/BaseArrayHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/helpers/BaseArrayHelper.php b/framework/helpers/BaseArrayHelper.php index 1ff90bca00..77f800744d 100644 --- a/framework/helpers/BaseArrayHelper.php +++ b/framework/helpers/BaseArrayHelper.php @@ -401,7 +401,7 @@ class BaseArrayHelper * `SORT_REGULAR`, `SORT_NUMERIC`, `SORT_STRING`, `SORT_LOCALE_STRING`, `SORT_NATURAL` and `SORT_FLAG_CASE`. * Please refer to [PHP manual](http://php.net/manual/en/function.sort.php) * for more details. When sorting by multiple keys with different sort flags, use an array of sort flags. - * @throws InvalidParamException if the $descending or $sortFlag parameters do not have + * @throws InvalidParamException if the $direction or $sortFlag parameters do not have * correct number of elements as that of $key. */ public static function multisort(&$array, $key, $direction = SORT_ASC, $sortFlag = SORT_REGULAR) @@ -414,7 +414,7 @@ class BaseArrayHelper if (is_scalar($direction)) { $direction = array_fill(0, $n, $direction); } elseif (count($direction) !== $n) { - throw new InvalidParamException('The length of $descending parameter must be the same as that of $keys.'); + throw new InvalidParamException('The length of $direction parameter must be the same as that of $keys.'); } if (is_scalar($sortFlag)) { $sortFlag = array_fill(0, $n, $sortFlag); From 1bcf3b8427c3c3fb102a179e427cc380abea6bd2 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 5 May 2014 08:12:21 -0400 Subject: [PATCH 25/43] Fixed wrong links [skip ci] --- extensions/bootstrap/ActiveField.php | 6 +++--- extensions/bootstrap/ActiveForm.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/bootstrap/ActiveField.php b/extensions/bootstrap/ActiveField.php index 1aa8c33426..d5b578df5f 100644 --- a/extensions/bootstrap/ActiveField.php +++ b/extensions/bootstrap/ActiveField.php @@ -11,13 +11,13 @@ use yii\helpers\Html; use yii\helpers\ArrayHelper; /** - * A Bootstrap 3 enhanced version of [[yii\widgets\ActiveField]]. + * A Bootstrap 3 enhanced version of [[\yii\widgets\ActiveField]]. * - * This class adds some useful features to [[yii\widgets\ActiveField|ActiveField]] to render all + * This class adds some useful features to [[\yii\widgets\ActiveField|ActiveField]] to render all * sorts of Bootstrap 3 form fields in different form layouts: * * - [[inputTemplate]] is an optional template to render complex inputs, for example input groups - * - [[horizontalClass]] defines the CSS grid classes to add to label, wrapper, error and hint + * - [[horizontalCssClasses]] defines the CSS grid classes to add to label, wrapper, error and hint * in horizontal forms * - [[inline]]/[[inline()]] is used to render inline [[checkboxList()]] and [[radioList()]] * - [[enableError]] can be set to `false` to disable to the error diff --git a/extensions/bootstrap/ActiveForm.php b/extensions/bootstrap/ActiveForm.php index 58bbf54beb..5ac1b1ae69 100644 --- a/extensions/bootstrap/ActiveForm.php +++ b/extensions/bootstrap/ActiveForm.php @@ -12,7 +12,7 @@ use yii\helpers\Html; use yii\base\InvalidConfigException; /** - * A Bootstrap 3 enhanced version of [[yii\widgets\ActiveForm]]. + * A Bootstrap 3 enhanced version of [[\yii\widgets\ActiveForm]]. * * This class mainly adds the [[layout]] property to choose a Bootstrap 3 form layout. * So for example to render a horizontal form you would: From 693b9a8b6bb9415fe3496364c5a65bd40cc1a3fe Mon Sep 17 00:00:00 2001 From: tsvetann Date: Mon, 5 May 2014 17:05:59 +0200 Subject: [PATCH 26/43] Update concept-behaviors.md fixed spelling --- docs/guide/concept-behaviors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/concept-behaviors.md b/docs/guide/concept-behaviors.md index 28429acaef..6d37cb5be3 100644 --- a/docs/guide/concept-behaviors.md +++ b/docs/guide/concept-behaviors.md @@ -184,7 +184,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 provide two properties `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 an ancestor class of [[yii\base\Behavior]], which supports defining [properties](concept-properties.md) by getters/setters. From cc818bf043fc60addd6ceb0ae059e65170a4e571 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 5 May 2014 11:19:52 -0400 Subject: [PATCH 27/43] updated guide toc [skip ci] --- docs/guide/README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/guide/README.md b/docs/guide/README.md index e8c54f5624..afe817ecbc 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -18,11 +18,13 @@ Introduction Getting Started --------------- -* [Preparing Your Environment](start-environment.md) -* [Creating Your First Yii Application](start-basic.md) -* [Application Structure](start-structure.md) -* [Request Lifecycle](start-lifecycle.md) -* **TBD** [Next Steps](start-next-steps.md) +* [Installing Yii](start-installation.md) +* [Running Applications](start-workflow.md) +* [Saying "Hello World"](start-hello-world.md) +* [Working with Forms](start-forms.md) +* [Working with Databases](start-databases.md) +* [Generating Code with Gii](start-gii.md) +* [Looking Ahead](start-looking-head.md) Application Structure @@ -77,8 +79,8 @@ Working with Databases * **TBD** [ElasticSearch](db-elastic-search.md) -Getting User Inputs -------------------- +Getting Data from Users +----------------------- * [Creating Forms](input-forms.md) * [Input Validation](input-validation.md) @@ -86,7 +88,7 @@ Getting User Inputs * **TBD** [Inputs for Multiple Models](input-multiple-models.md) -Presenting Data +Displaying Data --------------- * **TBD** [Data Formatting](output-formatting.md) @@ -190,7 +192,6 @@ Widgets * **TBD** [Jquery UI Widgets](jui-widgets.md) - Helpers ------- From c63e95418bdd2f3b100fadd6a5e3bf2b5b4edc11 Mon Sep 17 00:00:00 2001 From: Larry Ullman Date: Mon, 5 May 2014 10:34:59 -0400 Subject: [PATCH 28/43] Cleaned Up No major changes. Looks good! --- docs/guide/intro-yii.md | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/guide/intro-yii.md b/docs/guide/intro-yii.md index 1c97908026..41c1e4aa15 100644 --- a/docs/guide/intro-yii.md +++ b/docs/guide/intro-yii.md @@ -2,8 +2,8 @@ What is Yii =========== Yii is a high performance, component-based PHP framework for rapidly developing modern Web applications. -The name Yii (pronounced `Yee` or `[ji:]`) means simple and evolutionary in Chinese. It can also -be considered as the acronym for **Yes It Is**! +The name Yii (pronounced `Yee` or `[ji:]`) means "simple and evolutionary" in Chinese. It can also +be thought of as an acronym for **Yes It Is**! What is Yii Best for? @@ -22,17 +22,17 @@ How does Yii Compare with Other Frameworks? organization based on this pattern. - Yii takes the philosophy that code should be written in a simple yet elegant way. It will never try to over-design things mainly for the purpose of following some design pattern. -- Yii is a full-stack framework providing many proven and ready-to-use features, such as query builders - and ActiveRecord supporting relational and NoSQL databases, RESTful API development support, multi-tier - caching support, etc. +- Yii is a full-stack framework providing many proven and ready-to-use features, such as: query builders + and ActiveRecord, for both relational and NoSQL databases; RESTful API development support; multi-tier + caching support; and more. - Yii is extremely extensible. You can customize or replace nearly every piece of core code. You can also - take advantage of its solid extension architecture, use or develop redistributable extensions. + take advantage of its solid extension architecture, to use or develop redistributable extensions. - High performance is always a primary goal of Yii. Yii is not a one-man show, it is backed up by a [strong core developer team][] as well as a large community -with many professionals who are constantly contributing to the development of Yii. The Yii developer team -is keeping a close eye on the latest trends of Web development and the best practices and features -found in other frameworks and projects. They are being carefully incorporated into the core framework and exposed +with many professionals constantly contributing to the development of Yii. The Yii developer team +keeps a close eye on the latest trends of Web development, and on the best practices and features +found in other frameworks and projects. The most relevant best practices and features found elsewhere are regularly incorporated into the core framework and exposed via simple and elegant interfaces. [strong core developer team]: http://www.yiiframework.com/about/ @@ -40,9 +40,8 @@ via simple and elegant interfaces. Yii Versions ------------ -Yii has two major versions available currently: 1.1 and 2.0. Version 1.1 is the old generation and is -currently under maintenance mode. Version 2.0 is a complete rewrite of Yii by adopting the latest -technologies and protocols, such as Composer, PSR, namespaces, traits, etc. Version 2.0 represents the latest +Yii currently has two major versions available: 1.1 and 2.0. Version 1.1 is the old generation and is now in maintenance mode. Version 2.0 is a complete rewrite of Yii, adopting the latest +technologies and protocols, including Composer, PSR, namespaces, traits, and so forth. Version 2.0 represents the latest generation of the framework and will receive our main development efforts in the next few years. This guide is mainly about version 2.0. @@ -50,11 +49,10 @@ This guide is mainly about version 2.0. Requirements and Prerequisites ------------------------------ -Yii 2.0 requires PHP 5.4.0 or above. You may find out more detailed requirements for individual features -by running the requirement checker included in every release. +Yii 2.0 requires PHP 5.4.0 or above. You can find more detailed requirements for individual features +by running the requirement checker included in every Yii release. Using Yii requires basic knowledge about object-oriented programming (OOP), as Yii is a pure OOP-based framework. -Yii 2.0 also makes use of the latest features of PHP, such as [namespaces](http://www.php.net/manual/en/language.namespaces.php), -[traits](http://www.php.net/manual/en/language.oop5.traits.php). Understanding these concepts will help -you pick up Yii 2.0 more easily. +Yii 2.0 also makes use of the latest features of PHP, such as [namespaces](http://www.php.net/manual/en/language.namespaces.php) and [traits](http://www.php.net/manual/en/language.oop5.traits.php). Understanding these concepts will help +you more easily pick up Yii 2.0. From 210487bfe57cedc96ea3b8a20831dfd094962b9b Mon Sep 17 00:00:00 2001 From: Larry Ullman Date: Mon, 5 May 2014 11:55:07 -0400 Subject: [PATCH 29/43] Edited up through "I18N" --- docs/guide/intro-upgrade-from-v1.md | 140 ++++++++++++++-------------- 1 file changed, 68 insertions(+), 72 deletions(-) diff --git a/docs/guide/intro-upgrade-from-v1.md b/docs/guide/intro-upgrade-from-v1.md index 62b9f98cc0..d944641195 100644 --- a/docs/guide/intro-upgrade-from-v1.md +++ b/docs/guide/intro-upgrade-from-v1.md @@ -1,30 +1,29 @@ Upgrading from Version 1.1 ========================== -There are many differences between Yii version 2.0 and 1.1, because Yii is completely rewritten for 2.0. -As a result, upgrading from version 1.1 is not as trivial as upgrading between minor versions. In this chapter, -we will summarize the major differences between the two versions. +There are many differences between versions 1.1 and 2.0 of the Yii as the framework was completely rewritten for 2.0. +As a result, upgrading from version 1.1 is not as trivial as upgrading between minor versions. In this guide you'll find the major differences between the two versions. -Please note that Yii 2.0 introduces many new features which are not covered in this summary. It is highly recommended -that you read through the whole definitive guide to learn about these features. Chances could be that -some features you previously have to develop by yourself are already part of the core code now. +Please note that Yii 2.0 introduces more new features than are covered in this summary. It is highly recommended +that you read through the whole definitive guide to learn about them all. Chances are that +some features you previously had to develop for yourself are now part of the core code. Installation ------------ -Yii 2.0 fully embraces [Composer](https://getcomposer.org/), a de facto PHP package manager. Installation -of the core framework as well as extensions are all installed through Composer. Please refer to -the [Starting from Basic App](start-basic.md) chapter to learn how to install Yii 2.0. If you want to -create new extensions or turn your existing 1.1 extensions into 2.0, please refer to -the [Creating Extensions](extend-creating-extensions.md) chapter. +Yii 2.0 fully embraces [Composer](https://getcomposer.org/), the de facto PHP package manager. Installation +of the core framework, as well as extensions, are handled through Composer. Please refer to +the [Starting from Basic App](start-basic.md) section to learn how to install Yii 2.0. If you want to +create new extensions, or turn your existing 1.1 extensions into 2.0-compatible extensions, please refer to +the [Creating Extensions](extend-creating-extensions.md) section of the guide. PHP Requirements ---------------- -Yii 2.0 requires PHP 5.4 or above, which is a huge improvement over PHP 5.2 as required by Yii 1.1. -As a result, there are many differences at language level that you should pay attention to. +Yii 2.0 requires PHP 5.4 or above, which is a huge improvement over PHP version 5.2 that is required by Yii 1.1. +As a result, there are many differences on the language level that you should pay attention to. Below is a summary of the major changes regarding PHP: - [Namespaces](http://php.net/manual/en/language.namespaces.php). @@ -44,10 +43,11 @@ Namespace The most obvious change in Yii 2.0 is the use of namespaces. Almost every core class is namespaced, e.g., `yii\web\Request`. The "C" prefix is no longer used in class names. -The naming of the namespaces follows the directory structure. For example, `yii\web\Request` -indicates the corresponding class file is `web/Request.php` under the Yii framework folder. -You can use any core class without explicitly including that class file, thanks to the Yii -class loader. +The naming scheme now follows the directory structure. For example, `yii\web\Request` +indicates that the corresponding class file is `web/Request.php` under the Yii framework folder. + +(You can use any core class without explicitly including that class file, thanks to the Yii +class loader.) Component and Object @@ -90,12 +90,12 @@ class MyClass extends \yii\base\Object ``` In the above, the last parameter of the constructor must take a configuration array -which contains name-value pairs for initializing the properties at the end of the constructor. +that contains name-value pairs for initializing the properties at the end of the constructor. You can override the [[yii\base\Object::init()|init()]] method to do initialization work that should be done after -the configuration is applied. +the configuration has been applied. -By following this convention, you will be able to create and configure a new object -using a configuration array like the following: +By following this convention, you will be able to create and configure new objects +using a configuration array: ```php $object = Yii::createObject([ @@ -105,14 +105,13 @@ $object = Yii::createObject([ ], [$param1, $param2]); ``` -More details about configurations can be found in the [Object Configurations](concept-configurations.md) chapter. +More details about configurations can be found in the [Object Configurations](concept-configurations.md) section. Events ------ -There is no longer the need to define an `on`-method in order to define an event in Yii 2.0. -Instead, you can use whatever event names. You can trigger an event by calling +In Yii 1, events were created by defining an `on`-method (e.g., `onBeforeSave`). In Yii 2, you can now use any event name. You trigger an event by calling the [[yii\base\Component::trigger()|trigger()]] method: ```php @@ -120,7 +119,7 @@ $event = new \yii\base\Event; $component->trigger($eventName, $event); ``` -And to attach a handler to an event, you can use the [[yii\base\Component::on()|on()]] method: +To attach a handler to an event, use the [[yii\base\Component::on()|on()]] method: ```php $component->on($eventName, $handler); @@ -128,39 +127,38 @@ $component->on($eventName, $handler); // $component->off($eventName, $handler); ``` -There are many enhancements to the event features. For more details, please refer to the [Events](concept-events.md) chapter. +There are many enhancements to the event features. For more details, please refer to the [Events](concept-events.md) section. Path Aliases ------------ -Yii 2.0 expands the usage of path aliases to both file/directory paths and URLs. It also requires -an alias name to start with a `@` character so that it can be differentiated from normal file/directory paths and URLs. +Yii 2.0 expands the usage of path aliases to both file/directory paths and URLs. Yii 2.0 also now requires +an alias name to start with the `@` character, to differentiate aliases from normal file/directory paths or URLs. For example, the alias `@yii` refers to the Yii installation directory. Path aliases are supported in most places in the Yii core code. For example, [[yii\caching\FileCache::cachePath]] can take both a path alias and a normal directory path. -Path alias is also closely related with class namespaces. It is recommended that a path -alias be defined for each root namespace so that you can use Yii the class autoloader without +A path alias is also closely related to a class namespace. It is recommended that a path +alias be defined for each root namespace, thereby allowing you to use Yii the class autoloader without any further configuration. For example, because `@yii` refers to the Yii installation directory, -a class like `yii\web\Request` can be autoloaded by Yii. If you use a third party library -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. +a class like `yii\web\Request` can be autoloaded. If you use a third party library, +such as the Zend Framework, you may define a path alias `@Zend` that refers to that framework's installation +directory. Once you've done that, Yii will be able to autoload any class in that Zend Framework library, too. -More on path aliases can be found in the [Path Aliases](concept-aliases.md) chapter. +More on path aliases can be found in the [Path Aliases](concept-aliases.md) section. Views ----- -The most significant change about views is that `$this` in a view no longer refers to -the current controller or widget. Instead, it refers to a *view* object which is a new concept -introduced in 2.0. The *view* object is of class [[yii\web\View]] which represents the view part -of the MVC pattern. In you want to access the controller or widget in a view, you should use `$this->context`. +The most significant change about views in Yii 2 is that the special variable `$this` in a view no longer refers to +the current controller or widget. Instead, `$this` now refers to a *view* object, a new concept +introduced in 2.0. The *view* object is of type [[yii\web\View]], which represents the view part +of the MVC pattern. In you want to access the controller or widget in a view, you can use `$this->context`. -To render a partial view within another view, you should use `$this->render()` now. -And you have to echo it explicitly because the `render()` method will return the rendering -result rather than directly displaying it. For example, +To render a partial view within another view, you use `$this->render()`, not `$this->renderPartial()`. The call to `render` also now has to be explicitly echoed, as the `render()` method returns the rendering +result, rather than directly displaying it. For example: ```php echo $this->render('_item', ['item' => $item]); @@ -170,18 +168,17 @@ Besides using PHP as the primary template language, Yii 2.0 is also equipped wit support for two popular template engines: Smarty and Twig. The Prado template engine is no longer supported. To use these template engines, you need to configure the `view` application component by setting the [[yii\base\View::$renderers|View::$renderers]] property. Please refer to the [Template Engines](tutorial-template-engines.md) -chapter for more details. +section for more details. Models ------ -Yii 2.0 uses [[yii\base\Model]] as the base model class which is similar to `CModel` in 1.1. -The class `CFormModel` is dropped. Instead, you should extend [[yii\base\Model]] to create a form model class. +Yii 2.0 uses [[yii\base\Model]] as the base model, similar to `CModel` in 1.1. +The class `CFormModel` has been dropped entirely. Instead, in Yii 2 you should extend [[yii\base\Model]] to create a form model class. Yii 2.0 introduces a new method called [[yii\base\Model::scenarios()|scenarios()]] to declare -supported scenarios and under which scenario an attribute needs to be validated and can be considered as safe or not. -For example, +supported scenarios, and to indicate under which scenario an attribute needs to be validated, can be considered as safe or not, etc. For example: ```php public function scenarios() @@ -193,28 +190,27 @@ public function scenarios() } ``` -In the above, two scenarios are declared: `backend` and `frontend`. For the `backend` scenario, both of the -`email` and `role` attributes are safe and can be massively assigned; for the `frontend` scenario, -`email` can be massively assigned while `role` cannot. Both `email` and `role` should be validated. +In the above, two scenarios are declared: `backend` and `frontend`. For the `backend` scenario, both the +`email` and `role` attributes are safe, and can be massively assigned. For the `frontend` scenario, +`email` can be massively assigned while `role` cannot. Both `email` and `role` should be validated using rules. -The [[yii\base\Model::rules()|rules()]] method is still used to declare validation rules. Note that because -of the introduction of [[yii\base\Model::scenarios()|scenarios()]], there is no more `unsafe` validator. +The [[yii\base\Model::rules()|rules()]] method is still used to declare the validation rules. Note that due to the introduction of [[yii\base\Model::scenarios()|scenarios()]], there is no longer an `unsafe` validator. In most cases, you do not need to override [[yii\base\Model::scenarios()|scenarios()]] -if the [[yii\base\Model::rules()|rules()]] method fully specifies the scenarios and there is no need to declare +if the [[yii\base\Model::rules()|rules()]] method fully specifies the scenarios that will exist, and if there is no need to declare `unsafe` attributes. -To learn more details about models, please refer to the [Models](basic-models.md) chapter. +To learn more details about models, please refer to the [Models](basic-models.md) section. Controllers ----------- -Yii 2.0 uses [[yii\web\Controller]] as the base controller class which is similar to `CWebController` in 1.1. -And [[yii\base\Action]] is the base class for action classes. +Yii 2.0 uses [[yii\web\Controller]] as the base controller class, similar to `CWebController` in Yii 1.1. +[[yii\base\Action]] is the base class for action classes. -The most obvious change when you write code in a controller action is that you should return the content -that you want to render instead of echoing it. For example, +The most obvious impact of these changes on your code is that a controller action should return the content +that you want to render instead of echoing it: ```php public function actionView($id) @@ -228,17 +224,17 @@ public function actionView($id) } ``` -Please refer to the [Controllers](structure-controllers.md) chapter for more details about controllers. +Please refer to the [Controllers](structure-controllers.md) section for more details about controllers. Widgets ------- -Yii 2.0 uses [[yii\base\Widget]] as the base widget class which is similar to `CWidget` in 1.1. +Yii 2.0 uses [[yii\base\Widget]] as the base widget class, similar to `CWidget` in Yii 1.1. -To get better IDE support, Yii 2.0 introduces a new syntax for using widgets. The static methods -[[yii\base\Widget::begin()|begin()]], [[yii\base\Widget::end()|end()]] and [[yii\base\Widget::widget()|widget()]] -are introduced and can be used as follows, +To get better support for the framework in IDEs, Yii 2.0 introduces a new syntax for using widgets. The static methods +[[yii\base\Widget::begin()|begin()]], [[yii\base\Widget::end()|end()]], and [[yii\base\Widget::widget()|widget()]] +have been introduced, to be used like so: ```php use yii\widgets\Menu; @@ -256,29 +252,29 @@ $form = ActiveForm::begin([ ActiveForm::end(); ``` -Please refer to the [Widgets](structure-widgets.md) chapter for more details. +Please refer to the [Widgets](structure-widgets.md) section for more details. Themes ------ -Themes work completely different in 2.0. They are now based on a path mapping mechanism which maps a source +Themes work completely differently in 2.0. They are now based on a path mapping mechanism that maps a source view file path to a themed view file path. For example, if the path map for a theme is -`['/web/views' => '/web/themes/basic']`, then the themed version for a view file +`['/web/views' => '/web/themes/basic']`, then the themed version for the view file `/web/views/site/index.php` will be `/web/themes/basic/site/index.php`. For this reason, themes can now -be applied to any view file, even if a view rendered outside of the context of a controller or a widget. +be applied to any view file, even a view rendered outside of the context of a controller or a widget. -Also, there is no more `CThemeManager`. Instead, `theme` is a configurable property of the `view` +Also, there is no more `CThemeManager` component. Instead, `theme` is a configurable property of the `view` application component. -Please refer to the [Theming](tutorial-theming.md) chapter for more details. +Please refer to the [Theming](tutorial-theming.md) section for more details. Console Applications -------------------- Console applications are now organized as controllers, like Web applications. Console controllers -should extend from [[yii\console\Controller]] which is similar to `CConsoleCommand` in 1.1. +should extend from [[yii\console\Controller]], similar to `CConsoleCommand` in 1.1. To run a console command, use `yii `, where `` stands for a controller route (e.g. `sitemap/index`). Additional anonymous arguments are passed as the parameters to the @@ -293,13 +289,13 @@ Please refer to the [Console Commands](tutorial-console.md) chapter for more det I18N ---- -Yii 2.0 removes date formatter and number formatter in favor of the PECL intl PHP module. +Yii 2.0 removes the built-in date formatter and number formatter pieces in favor of the [PECL intl PHP module](http://pecl.php.net/package/intl). Message translation is now performed via the `i18n` application component. -The component manages a set of message sources, which allows you to use different message +This component manages a set of message sources, which allows you to use different message sources based on message categories. -Please refer to the [Internationalization](tutorial-i18n.md) chapter for more details. +Please refer to the [Internationalization](tutorial-i18n.md) section for more details. Action Filters From 15135b8071b24ea6ece6e683fac759a91569a8cc Mon Sep 17 00:00:00 2001 From: larnu Date: Mon, 5 May 2014 19:46:57 +0200 Subject: [PATCH 30/43] Catalan translation --- framework/messages/ca/yii.php | 107 ++++++++++++++++++++++++++++++++++ framework/messages/config.php | 2 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 framework/messages/ca/yii.php diff --git a/framework/messages/ca/yii.php b/framework/messages/ca/yii.php new file mode 100644 index 0000000000..62d2ffe12d --- /dev/null +++ b/framework/messages/ca/yii.php @@ -0,0 +1,107 @@ + 'S\'ha produït un error intern al servidor.', + 'Are you sure to delete this item?' => '¿Estás segur d\'eliminar aquest element?', + 'Are you sure you want to delete this item?' => 'Estas segur que vols eliminar aquest element?', + '{attribute} cannot be blank.' => '{attribute} no pot estar buit.', + '{attribute} is invalid.' => '{attribute} és invalid.', + '{attribute} is not a valid email address.' => '{attribute} no es una direcció de correu valida.', + '{attribute} is not a valid URL.' => '{attribute} no és una URL valida.', + '{attribute} must be an integer.' => '{attribute} ha de ser un nombre enter.', + '{attribute} must be a number.' => '{attribute} ha de ser un nombre.', + '{attribute} must be a string.' => '{attribute} ha de ser una cadena de caràcters.', + '{attribute} must be either "{true}" or "{false}".' => '{attribute} ha de ser "{true}" o "{false}".', + '{attribute} must be greater than "{compareValue}".' => '{attribute} ha de ser major que "{compareValue}', + '{attribute} must be greater than or equal to "{compareValue}".' => '{attribute} ha de ser major o igual que "{compareValue}".', + '{attribute} must be less than "{compareValue}".' => '{attribute} ha de ser menor que "{compareValue}".', + '{attribute} must be less than or equal to "{compareValue}".' => '{attribute} ha de ser menor o igual que "{compareValue}".', + '{attribute} must be no greater than {max}.' => '{attribute} no pot ser major que {max}.', + '{attribute} must be no less than {min}.' => '{attribute} no pot ser menor que {min}.', + '{attribute} must be repeated exactly.' => '{attribute} ha de ser repetit exactament igual.', + '{attribute} must be "{requiredValue}".' => '{attribute} ha de ser "{requiredValue}".', + '{attribute} must not be equal to "{compareValue}".' => '{attribute} no pot ser igual que "{compareValue}".', + '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute} hauria de contenir com a mínim {min, number} {min, plural, one{lletra} other{lletres}}.', + '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => '{attribute} hauria de contenir com a màxim {max, number} {max, plural, one{lletra} other{lletres}}.', + '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => '{attribute} hauria contenir {length, number} {length, plural, one{lletra} other{lletres}}.', + '{attribute} "{value}" has already been taken.' => '{attribute} "{value}" ja ha sigut utilitzat.', + 'Delete' => 'Eliminar', + '{delta, plural, =1{a day} other{# days}} ago' => 'hace {delta, plural, =1{un dia} other{# dies}}', + '{delta, plural, =1{a minute} other{# minutes}} ago' => 'fa {delta, plural, =1{un minut} other{# minuts}}', + '{delta, plural, =1{a month} other{# months}} ago' => 'fa {delta, plural, =1{un mes} other{# mesos}}', + '{delta, plural, =1{an hour} other{# hours}} ago' => 'fa {delta, plural, =1{una hora} other{# hores}}', + '{delta, plural, =1{a second} other{# seconds}} ago' => 'fa {delta, plural, =1{un segon} other{# segons}}', + '{delta, plural, =1{a year} other{# years}} ago' => 'fa {delta, plural, =1{un any} other{# anys}}', + 'Error' => 'Error', + 'File upload failed.' => 'Ha fallat la pujada del fitxer.', + 'Home' => 'Inici', + 'in {delta, plural, =1{a day} other{# days}}' => 'en {delta, plural, =1{un dia} other{# dies}}', + 'in {delta, plural, =1{a minute} other{# minutes}}' => 'en {delta, plural, =1{un minut} other{# minuts}}', + 'in {delta, plural, =1{a month} other{# months}}' => 'en {delta, plural, =1{un mes} other{# mesos}}', + 'in {delta, plural, =1{an hour} other{# hours}}' => 'en {delta, plural, =1{una hora} other{# hores}}', + 'in {delta, plural, =1{a second} other{# seconds}}' => 'en {delta, plural, =1{un segon} other{# segons}}', + 'in {delta, plural, =1{a year} other{# years}}' => 'en {delta, plural, =1{un any} other{# anys}}', + 'Invalid data received for parameter "{param}".' => 'S\'han rebut dades errònies pel paràmetre "{param}"', + 'Login Required' => 'Login Requerit', + 'Missing required arguments: {params}' => 'Falten arguments requerits: {params}', + 'Missing required parameters: {params}' => 'Falten paràmetres requerits: {params}', + '{n} B' => '{n} B', + '{n} GB' => '{n} GB', + '{n} KB' => '{n} KB', + '{n} MB' => '{n} MB', + 'No help for unknown command "{command}".' => 'No hi ha ajuda per l\'ordre desconeguda "{command}"', + 'No help for unknown sub-command "{command}".' => 'No hi ha ajuda per la sub-ordre desconeguda "{command}"', + 'No' => 'No', + 'No results found.' => 'No s\'han trobat resultats.', + '(not set)' => '(no establert)', + '{n} PB' => '{n} PB', + '{n, plural, =1{# byte} other{# bytes}}' => '{n, plural, =1{# byte} other{# bytes}}', + '{n, plural, =1{# gigabyte} other{# gigabytes}}' => '{n, plural, =1{# gigabyte} other{# gigabytes}}', + '{n, plural, =1{# kilobyte} other{# kilobytes}}' => '{n, plural, =1{# kilobyte} other{# kilobytes}}', + '{n, plural, =1{# megabyte} other{# megabytes}}' => '{n, plural, =1{# megabyte} other{# megabytes}}', + '{n, plural, =1{# petabyte} other{# petabytes}}' => '{n, plural, =1{# petabyte} other{# petabytes}}', + '{n, plural, =1{# terabyte} other{# terabytes}}' => '{n, plural, =1{# terabyte} other{# terabytes}}', + '{n} TB' => '{n} TB', + 'Only files with these extensions are allowed: {extensions}.' => 'Només s\'accepten arxius amb les seguents extensions: {extensions}', + 'Only files with these mimeTypes are allowed: {mimeTypes}.' => 'Només s\'accepten arxius amb els seguents tipus MIME: {mimeTypes}', + 'Only files with these MIME types are allowed: {mimeTypes}.' => 'Només s\'accepten arxius amb els següents tipus MIME: {mimeTypes}.', + 'Page not found.' => 'No s\'ha trobat la pàgina.', + 'Please fix the following errors:' => 'Si us plau corregeix els següents errors:', + 'Please upload a file.' => 'Si us plau puja un arxiu.', + 'Showing {begin, number}-{end, number} of {totalCount, number} {totalCount, plural, one{item} other{items}}.' => 'Mostrant {begin, number}-{end, number} de {totalCount, number} {totalCount, plural, one{element} other{elements}}.', + 'The file "{file}" is not an image.' => 'L\'arxiu "{file}" no és una imatge.', + 'The file "{file}" is too big. Its size cannot exceed {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'L\'arxiu "{file}" és massa gran. El seu tamany no pot excedir {limit, number} {limit, plural, one{byte} other{bytes}}.', + 'The file "{file}" is too small. Its size cannot be smaller than {limit, number} {limit, plural, one{byte} other{bytes}}.' => 'L\'arxiu "{file}" és massa petit. El seu tamany no pot ser menor que {limit, number} {limit, plural, one{byte} other{bytes}}.', + 'The format of {attribute} is invalid.' => 'El format de {attribute} és invalid.', + 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'La imatge "{file}" és massa gran. L\'altura no pot ser major que {limit, number} {limit, plural, one{píxel} other{píxels}}.', + 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'La imatge "{file}" és massa gran. L\'amplada no pot ser major que {limit, number} {limit, plural, one{píxel} other{píxels}}.', + 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'La imatge "{file}" és massa petita. L\'altura no pot ser menor que {limit, number} {limit, plural, one{píxel} other{píxels}}.', + 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.' => 'La imatge "{file}" és massa petita. L\'amplada no pot ser menor que {limit, number} {limit, plural, one{píxel} other{píxels}}.', + 'the input value' => 'el valor d\'entrada', + 'The verification code is incorrect.' => 'El codi de verificació és incorrecte.', + 'Total {count, number} {count, plural, one{item} other{items}}.' => 'Total {count, number} {count, plural, one{element} other{elements}}.', + 'Unable to verify your data submission.' => 'No s\'ha pogut verificar les dades enviades.', + 'Unknown command "{command}".' => 'Ordre desconeguda "{command}".', + 'Unknown option: --{name}' => 'Opció desconeguda: --{name}', + 'Update' => 'Actualitzar', + 'View' => 'Veure', + 'Yes' => 'Sí', + 'You are not allowed to perform this action.' => 'No tems permís per executar aquesta acció.', + 'You can upload at most {limit, number} {limit, plural, one{file} other{files}}.' => 'Pots pujar com a màxim {limit, number} {limit, plural, one{arxiu} other{arxius}}.', +); diff --git a/framework/messages/config.php b/framework/messages/config.php index 7bad25975b..c9f32793bd 100644 --- a/framework/messages/config.php +++ b/framework/messages/config.php @@ -7,7 +7,7 @@ return [ 'messagePath' => __DIR__, // array, required, list of language codes that the extracted messages // should be translated to. For example, ['zh-CN', 'de']. - 'languages' => ['ar', 'bg', 'da', 'de', 'el', 'es', 'fa-IR', 'fi', 'fr', 'hu', 'it', 'ja', 'kk', 'lt', 'lv', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sr', 'sr-Latn', 'uk', 'vi', 'zh-CN'], + 'languages' => ['ar', 'bg', 'ca', 'da', 'de', 'el', 'es', 'fa-IR', 'fi', 'fr', 'hu', 'it', 'ja', 'kk', 'lt', 'lv', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sr', 'sr-Latn', 'uk', 'vi', 'zh-CN'], // string, the name of the function for translating messages. // Defaults to 'Yii::t'. This is used as a mark to find the messages to be // translated. You may use a string for single function name or an array for From ef71a97e571cc7d7cd7d4c7322b74ffa379644e5 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 5 May 2014 15:11:50 -0400 Subject: [PATCH 31/43] renamed chapter to section [skip ci] --- docs/guide/bootstrap-widgets.md | 2 +- docs/guide/caching-overview.md | 2 +- docs/guide/concept-autoloading.md | 2 +- docs/guide/concept-behaviors.md | 6 +++--- docs/guide/concept-configurations.md | 8 ++++---- docs/guide/concept-events.md | 4 ++-- docs/guide/db-active-record.md | 2 +- docs/guide/db-dao.md | 2 +- docs/guide/db-migrations.md | 2 +- docs/guide/db-query-builder.md | 2 +- docs/guide/extend-creating-extensions.md | 2 +- docs/guide/extend-customizing-core.md | 2 +- docs/guide/extend-using-composer.md | 2 +- docs/guide/extend-using-libs.md | 2 +- docs/guide/helper-overview.md | 2 +- docs/guide/input-forms.md | 2 +- docs/guide/input-validation.md | 2 +- docs/guide/intro-upgrade-from-v1.md | 12 ++++++------ docs/guide/output-assets.md | 2 +- docs/guide/output-data-providers.md | 2 +- docs/guide/output-data-widgets.md | 2 +- docs/guide/rest-quick-start.md | 6 +++--- docs/guide/runtime-url-handling.md | 2 +- docs/guide/security-authentication.md | 2 +- docs/guide/security-authorization.md | 2 +- docs/guide/security-passwords.md | 2 +- docs/guide/start-basic.md | 2 +- docs/guide/start-environment.md | 2 +- docs/guide/start-lifecycle.md | 2 +- docs/guide/start-structure.md | 2 +- docs/guide/structure-controllers.md | 2 +- docs/guide/structure-entry.md | 2 +- docs/guide/structure-models.md | 2 +- docs/guide/structure-views.md | 2 +- docs/guide/test-fixtures.md | 2 +- docs/guide/tool-debugger.md | 2 +- docs/guide/tool-gii.md | 2 +- docs/guide/tutorial-advanced-app.md | 2 +- docs/guide/tutorial-console.md | 2 +- docs/guide/tutorial-handling-errors.md | 2 +- docs/guide/tutorial-i18n.md | 2 +- docs/guide/tutorial-logging.md | 2 +- docs/guide/tutorial-performance-tuning.md | 2 +- docs/guide/tutorial-start-from-scratch.md | 2 +- docs/guide/tutorial-template-engines.md | 2 +- docs/guide/tutorial-theming.md | 2 +- 46 files changed, 59 insertions(+), 59 deletions(-) diff --git a/docs/guide/bootstrap-widgets.md b/docs/guide/bootstrap-widgets.md index a44298959a..ec33073a31 100644 --- a/docs/guide/bootstrap-widgets.md +++ b/docs/guide/bootstrap-widgets.md @@ -1,7 +1,7 @@ Bootstrap Widgets ================= -> Note: This chapter is under development. +> Note: This section is under development. Out of the box, Yii includes support for the [Bootstrap 3](http://getbootstrap.com/) markup and components framework (also known as "Twitter Bootstrap"). Bootstrap is an excellent, responsive framework that can greatly speed up the diff --git a/docs/guide/caching-overview.md b/docs/guide/caching-overview.md index 5fcee7d51e..714cfd29d1 100644 --- a/docs/guide/caching-overview.md +++ b/docs/guide/caching-overview.md @@ -1,7 +1,7 @@ Caching ======= -> Note: This chapter is under development. +> Note: This section is under development. Caching is a cheap and effective way to improve the performance of a web application. By storing relatively static data in cache and serving it from cache when requested, the application saves the time required to generate the data from scratch. Caching is one of the best ways to improve the performance of your application, almost mandatory on any large-scale site. diff --git a/docs/guide/concept-autoloading.md b/docs/guide/concept-autoloading.md index 0e6bfb0586..f6ca0855ca 100644 --- a/docs/guide/concept-autoloading.md +++ b/docs/guide/concept-autoloading.md @@ -6,7 +6,7 @@ to locate and include required class files. It provides a high-performance class [PSR-4 standard](https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader.md). The autoloader is installed when you include the `Yii.php` file. -> Note: For simplicity of description, in this chapter we will only talk about autoloading of classes. However, keep in +> Note: For simplicity of description, in this section we will only talk about autoloading of classes. However, keep in mind that the content we are describing here applies to autoloading of interfaces and traits as well. diff --git a/docs/guide/concept-behaviors.md b/docs/guide/concept-behaviors.md index 6d37cb5be3..b18033f248 100644 --- a/docs/guide/concept-behaviors.md +++ b/docs/guide/concept-behaviors.md @@ -15,7 +15,7 @@ Using Behaviors --------------- To use a behavior, you first need to attach it to a [[yii\base\Component|component]]. We will describe how to -attach a behavior in the next section. +attach a behavior in the next subsection. Once a behavior is attached to a component, its usage is straightforward. @@ -129,7 +129,7 @@ $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. +refer to the [Configurations](concept-configurations.md#configuration-format) section. @@ -227,7 +227,7 @@ its handler `beforeValidate()`. When specifying an event handler, you may use on * an anonymous function. The signature of an event handler should be as follows, where `$event` refers to the event parameter. Please refer -to the [Events](concept-events.md) chapter for more details about events. +to the [Events](concept-events.md) section for more details about events. ```php function ($event) { diff --git a/docs/guide/concept-configurations.md b/docs/guide/concept-configurations.md index a846ad0778..03ff3cea3b 100644 --- a/docs/guide/concept-configurations.md +++ b/docs/guide/concept-configurations.md @@ -58,7 +58,7 @@ where defined by getters/setters can be configured. * 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 - the [Events](concept-events.md) chapter for supported event handler formats. + the [Events](concept-events.md) section for supported event handler formats. * 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 the configuration for creating a behavior, like a normal configuration as we are describing here. @@ -84,8 +84,8 @@ Below is an example showing a configuration with property initial values, event Using Configurations -------------------- -Configurations are used in many places in Yii. At the beginning of this chapter, we have shown how to use -create an object according to a configuration by using [[Yii::createObject()]]. In this section, we will +Configurations are used in many places in Yii. At the beginning of this section, we have shown how to use +create an object according to a configuration by using [[Yii::createObject()]]. In this subsection, we will describe application configurations and widget configurations - two major usages of configurations. @@ -138,7 +138,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 -in the [Applications](structure-applications.md) chapter and the [Service Locator](concept-service-locator.md) chapter. +in the [Applications](structure-applications.md) section and the [Service Locator](concept-service-locator.md) section. diff --git a/docs/guide/concept-events.md b/docs/guide/concept-events.md index 82449ddd0a..3f5002265b 100644 --- a/docs/guide/concept-events.md +++ b/docs/guide/concept-events.md @@ -129,7 +129,7 @@ $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. +refer to the [Configurations](concept-configurations.md#configuration-format) section. When attaching an event handler, you may provide additional data as the third parameter to [[yii\base\Component::on()]]. @@ -201,7 +201,7 @@ $foo->off(Foo::EVENT_HELLO); Class-Level Event Handlers -------------------------- -In the above sections, we have described how to attach a handler to an event at *instance level*. +In the above subsections, we have described how to attach a handler to an event at *instance level*. Sometimes, you may want to respond to an event triggered by EVERY instance of a class instead of a specific instance. Instead of attaching an event handler to every instance, you may attach the handler at *class level* by calling the static method [[yii\base\Event::on()]]. diff --git a/docs/guide/db-active-record.md b/docs/guide/db-active-record.md index 1057ef7e11..584f8c7c5f 100644 --- a/docs/guide/db-active-record.md +++ b/docs/guide/db-active-record.md @@ -1,7 +1,7 @@ Active Record ============= -> Note: This chapter is under development. +> Note: This section is under development. [Active Record](http://en.wikipedia.org/wiki/Active_record_pattern) provides an object-oriented interface for accessing data stored in a database. An Active Record class is associated with a database table, diff --git a/docs/guide/db-dao.md b/docs/guide/db-dao.md index d529b290da..d5eac7d7ad 100644 --- a/docs/guide/db-dao.md +++ b/docs/guide/db-dao.md @@ -1,7 +1,7 @@ Database basics =============== -> Note: This chapter is under development. +> Note: This section is under development. Yii has a database access layer built on top of PHP's [PDO](http://www.php.net/manual/en/book.pdo.php). It provides uniform API and solves some inconsistencies between different DBMS. By default Yii supports the following DBMS: diff --git a/docs/guide/db-migrations.md b/docs/guide/db-migrations.md index afcb0e22f3..c591fa499a 100644 --- a/docs/guide/db-migrations.md +++ b/docs/guide/db-migrations.md @@ -1,7 +1,7 @@ Database Migration ================== -> Note: This chapter is under development. +> Note: This section is under development. Like source code, the structure of a database evolves as a database-driven application is developed and maintained. For example, during development, a new table may be added; Or, after the application goes live, it may be discovered that an additional index is required. It is important to keep track of these structural database changes (called **migration**), just as changes to the source code is tracked using version control. If the source code and the database become out of sync, bugs will occur, or the whole application might break. For this reason, Yii provides a database migration tool that can keep track of database migration history, apply new migrations, or revert existing ones. diff --git a/docs/guide/db-query-builder.md b/docs/guide/db-query-builder.md index a73613af08..b30aedff7d 100644 --- a/docs/guide/db-query-builder.md +++ b/docs/guide/db-query-builder.md @@ -1,7 +1,7 @@ Query Builder and Query ======================= -> Note: This chapter is under development. +> Note: This section is under development. Yii provides a basic database access layer as described in the [Database basics](database-basics.md) section. The database access layer provides a low-level way to interact with the database. While useful in some situations, diff --git a/docs/guide/extend-creating-extensions.md b/docs/guide/extend-creating-extensions.md index cb5e6ab3d0..d1ab25a691 100644 --- a/docs/guide/extend-creating-extensions.md +++ b/docs/guide/extend-creating-extensions.md @@ -1,7 +1,7 @@ Extending Yii ============= -> Note: This chapter is under development. +> Note: This section is under development. The Yii framework was designed to be easily extendable. Additional features can be added to your project and then reused, either by yourself on other projects or by sharing your work as a formal Yii extension. diff --git a/docs/guide/extend-customizing-core.md b/docs/guide/extend-customizing-core.md index ef05c915af..e9e8d6ce9c 100644 --- a/docs/guide/extend-customizing-core.md +++ b/docs/guide/extend-customizing-core.md @@ -1,7 +1,7 @@ Helper Classes ============== -> Note: This chapter is under development. +> Note: This section is under development. Yii provides many classes that help simplify common coding tasks, such as string or array manipulations, HTML code generation, and so forth. These helper classes are organized under the `yii\helpers` namespace and diff --git a/docs/guide/extend-using-composer.md b/docs/guide/extend-using-composer.md index 2da5bf9662..2058e3a2d5 100644 --- a/docs/guide/extend-using-composer.md +++ b/docs/guide/extend-using-composer.md @@ -1,7 +1,7 @@ Composer ======== -> Note: This chapter is under development. +> Note: This section is under development. Yii2 uses Composer as its dependency management tool. Composer is a PHP utility that can automatically handle the installation of needed libraries and extensions, thereby keeping those third-party resources up to date while absolving you of the need to manually manage the project's dependencies. diff --git a/docs/guide/extend-using-libs.md b/docs/guide/extend-using-libs.md index 805ff47a62..27fd2d7913 100644 --- a/docs/guide/extend-using-libs.md +++ b/docs/guide/extend-using-libs.md @@ -1,7 +1,7 @@ Using 3rd-Party Libraries ========================= -> Note: This chapter is under development. +> Note: This section is under development. Yii is carefully designed so that third-party libraries can be easily integrated to further extend Yii's functionalities. diff --git a/docs/guide/helper-overview.md b/docs/guide/helper-overview.md index 78a6d97832..df17c1fa2a 100644 --- a/docs/guide/helper-overview.md +++ b/docs/guide/helper-overview.md @@ -1,7 +1,7 @@ Helpers ======= -> Note: This chapter is under development. +> Note: This section is under development. Helper classes typically contain static methods only and are used as follows: diff --git a/docs/guide/input-forms.md b/docs/guide/input-forms.md index 74dac43c1d..144a07d036 100644 --- a/docs/guide/input-forms.md +++ b/docs/guide/input-forms.md @@ -1,7 +1,7 @@ Working with forms ================== -> Note: This chapter is under development. +> Note: This section is under development. The primary way of using forms in Yii is through [[yii\widgets\ActiveForm]]. This approach should be preferred when the form is based upon a model. Additionally, there are some useful methods in [[yii\helpers\Html]] that are typically diff --git a/docs/guide/input-validation.md b/docs/guide/input-validation.md index 9e775c6832..31e0275c9d 100644 --- a/docs/guide/input-validation.md +++ b/docs/guide/input-validation.md @@ -1,7 +1,7 @@ Model validation reference ========================== -> Note: This chapter is under development. +> Note: This section is under development. As a model both represents data and defines the business rules to which that data must adhere, comprehending data validation is key to using Yii. In order to learn model validation basics, please refer to [Model, Validation subsection](model.md#Validation). diff --git a/docs/guide/intro-upgrade-from-v1.md b/docs/guide/intro-upgrade-from-v1.md index d944641195..f981496ce7 100644 --- a/docs/guide/intro-upgrade-from-v1.md +++ b/docs/guide/intro-upgrade-from-v1.md @@ -283,7 +283,7 @@ the declarations in [[yii\console\Controller::options()]]. Yii 2.0 supports automatic generation of command help information from comment blocks. -Please refer to the [Console Commands](tutorial-console.md) chapter for more details. +Please refer to the [Console Commands](tutorial-console.md) section for more details. I18N @@ -320,7 +320,7 @@ public function behaviors() } ``` -Please refer to the [Filtering](runtime-filtering.md) chapter for more details. +Please refer to the [Filtering](runtime-filtering.md) section for more details. Assets @@ -334,7 +334,7 @@ By registering an asset bundle via [[yii\web\AssetBundle::register()]], you will the assets in that bundle accessible via Web, and the page registering the bundle will automatically contain the references to the JavaScript and CSS files specified in that bundle. -Please refer to the [Managing Assets](output-assets.md) chapter for more details. +Please refer to the [Managing Assets](output-assets.md) section for more details. Helpers @@ -390,7 +390,7 @@ $rows = $command->queryAll(); Best of all, such query building methods can also be used when working with [Active Record](db-active-record.md). -Please refer to the [Query Builder](db-query-builder.md) chapter for more details. +Please refer to the [Query Builder](db-query-builder.md) section for more details. Active Record @@ -446,7 +446,7 @@ $customers = Customer::find()->asArray()->all(); ``` There are many other changes and enhancements to Active Record. Please refer to -the [Active Record](db-active-record.md) chapter for more details. +the [Active Record](db-active-record.md) section for more details. User and IdentityInterface @@ -480,5 +480,5 @@ Using Yii 1.1 and 2.x together ------------------------------ If you have legacy Yii 1.1 code and you want to use it together with Yii 2.0, please refer to -the [Using Yii 1.1 and 2.0 Together](extend-using-v1-v2.md) chapter. +the [Using Yii 1.1 and 2.0 Together](extend-using-v1-v2.md) section. diff --git a/docs/guide/output-assets.md b/docs/guide/output-assets.md index 74ce909f7d..298655c86d 100644 --- a/docs/guide/output-assets.md +++ b/docs/guide/output-assets.md @@ -1,7 +1,7 @@ Managing assets =============== -> Note: This chapter is under development. +> Note: This section is under development. An asset in Yii is a file that is included into the page. It could be CSS, JavaScript or any other file. The framework provides many ways to work with assets from basics such as adding `