From 52654a9d634c93a5a46f176b4ec6137d3ddb81a8 Mon Sep 17 00:00:00 2001 From: Luciano Baraglia Date: Sun, 18 Aug 2013 12:07:33 -0300 Subject: [PATCH 1/5] Changed label for gii generated form [skip ci] --- framework/yii/gii/generators/form/templates/form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/yii/gii/generators/form/templates/form.php b/framework/yii/gii/generators/form/templates/form.php index 53cf5e6..0aa3215 100644 --- a/framework/yii/gii/generators/form/templates/form.php +++ b/framework/yii/gii/generators/form/templates/form.php @@ -27,7 +27,7 @@ use yii\widgets\ActiveForm;
- echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> + echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?>
ActiveForm::end(); ?> From 5e759790e4d501285d87679c6479bd2577395399 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 18 Aug 2013 19:31:07 +0200 Subject: [PATCH 2/5] fixed output of classMap controller --- build/controllers/ClassmapController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/controllers/ClassmapController.php b/build/controllers/ClassmapController.php index ca78e9e..f874824 100644 --- a/build/controllers/ClassmapController.php +++ b/build/controllers/ClassmapController.php @@ -55,7 +55,7 @@ class ClassmapController extends Controller $map = array(); foreach ($files as $file) { if (($pos = strpos($file, $root)) !== 0) { - die("Something wrong: $file"); + die("Something wrong: $file\n"); } $path = str_replace('\\', '/', substr($file, strlen($root))); $map[] = "\t'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII_PATH . '$path',"; @@ -80,10 +80,10 @@ $map EOD; if (is_file($mapFile) && file_get_contents($mapFile) === $output) { - echo "Nothing changed."; + echo "Nothing changed.\n"; } else { file_put_contents($mapFile, $output); - echo "Class map saved in $mapFile"; + echo "Class map saved in $mapFile\n"; } } } From bb2274eae22c590f5294bf613f0eaa17b0d2d2c2 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 18 Aug 2013 19:33:33 +0200 Subject: [PATCH 3/5] re-added Exception about wrong class name to autoloader helps reducing weird error messages. --- framework/yii/YiiBase.php | 21 +++++++++++++++++---- framework/yii/base/UnknownClassException.php | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 framework/yii/base/UnknownClassException.php diff --git a/framework/yii/YiiBase.php b/framework/yii/YiiBase.php index 2834d7e..a5a3833 100644 --- a/framework/yii/YiiBase.php +++ b/framework/yii/YiiBase.php @@ -9,6 +9,7 @@ namespace yii; use yii\base\Exception; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; +use yii\base\UnknownClassException; use yii\log\Logger; /** @@ -333,7 +334,11 @@ class YiiBase * it will attempt to include the file associated with the corresponding path alias * (e.g. `@PHPUnit/Framework/TestCase.php`); * + * This autoloader allows loading classes that follow the [PSR-0 standard](http://www.php-fig.org/psr/0/). + * Therefor a path alias has to be defined for each top-level namespace. + * * @param string $className the fully qualified class name without a leading backslash "\" + * @throws UnknownClassException if the class does not exist in the class file */ public static function autoload($className) { @@ -342,7 +347,6 @@ class YiiBase if ($classFile[0] === '@') { $classFile = static::getAlias($classFile); } - include($classFile); } else { // follow PSR-0 to determine the class file if (($pos = strrpos($className, '\\')) !== false) { @@ -354,13 +358,22 @@ class YiiBase } // try loading via path alias - if (strpos($path, '/') !== false) { + if (strpos($path, '/') === false) { + return; + } else { $classFile = static::getAlias('@' . $path, false); - if ($classFile !== false && is_file($classFile)) { - include($classFile); + if ($classFile === false || !is_file($classFile)) { + return; } } } + + include($classFile); + + if (!class_exists($className, false) && !interface_exists($className, false) && + (!function_exists('trait_exists') || !trait_exists($className, false))) { + throw new UnknownClassException("Unable to find '$className' in file: $classFile"); + } } /** diff --git a/framework/yii/base/UnknownClassException.php b/framework/yii/base/UnknownClassException.php new file mode 100644 index 0000000..8ccd09c --- /dev/null +++ b/framework/yii/base/UnknownClassException.php @@ -0,0 +1,25 @@ + + * @since 2.0 + */ +class UnknownClassException extends Exception +{ + /** + * @return string the user-friendly name of this exception + */ + public function getName() + { + return \Yii::t('yii', 'Unknown Class'); + } +} From 3d5a762bc5bd114a60ce964ed02a75a481fa7f7b Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 18 Aug 2013 19:40:29 +0200 Subject: [PATCH 4/5] exclude gii from classmap --- build/controllers/ClassmapController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/build/controllers/ClassmapController.php b/build/controllers/ClassmapController.php index f874824..a0599a3 100644 --- a/build/controllers/ClassmapController.php +++ b/build/controllers/ClassmapController.php @@ -49,6 +49,7 @@ class ClassmapController extends Controller '/debug/', '/console/', '/test/', + '/gii/', ), ); $files = FileHelper::findFiles($root, $options); From 2c5098860f4a6d79be9838c622318f6d6a18aedd Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 18 Aug 2013 19:40:51 +0200 Subject: [PATCH 5/5] sort classmap alphabetically to avoid producing different results on different file systems -> better diffs --- build/controllers/ClassmapController.php | 3 ++- framework/yii/classes.php | 39 ++++++++++++-------------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/build/controllers/ClassmapController.php b/build/controllers/ClassmapController.php index a0599a3..2a0483c 100644 --- a/build/controllers/ClassmapController.php +++ b/build/controllers/ClassmapController.php @@ -59,8 +59,9 @@ class ClassmapController extends Controller die("Something wrong: $file\n"); } $path = str_replace('\\', '/', substr($file, strlen($root))); - $map[] = "\t'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII_PATH . '$path',"; + $map[$path] = "\t'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII_PATH . '$path',"; } + ksort($map); $map = implode("\n", $map); $output = << YII_PATH . '/base/Request.php', 'yii\base\Response' => YII_PATH . '/base/Response.php', 'yii\base\Theme' => YII_PATH . '/base/Theme.php', + 'yii\base\UnknownClassException' => YII_PATH . '/base/UnknownClassException.php', 'yii\base\UnknownMethodException' => YII_PATH . '/base/UnknownMethodException.php', 'yii\base\UnknownPropertyException' => YII_PATH . '/base/UnknownPropertyException.php', 'yii\base\UserException' => YII_PATH . '/base/UserException.php', @@ -45,34 +46,21 @@ return array( 'yii\base\ViewRenderer' => YII_PATH . '/base/ViewRenderer.php', 'yii\base\Widget' => YII_PATH . '/base/Widget.php', 'yii\behaviors\AutoTimestamp' => YII_PATH . '/behaviors/AutoTimestamp.php', - 'yii\bootstrap\AffixAsset' => YII_PATH . '/bootstrap/AffixAsset.php', 'yii\bootstrap\Alert' => YII_PATH . '/bootstrap/Alert.php', - 'yii\bootstrap\AlertAsset' => YII_PATH . '/bootstrap/AlertAsset.php', 'yii\bootstrap\BootstrapAsset' => YII_PATH . '/bootstrap/BootstrapAsset.php', + 'yii\bootstrap\BootstrapPluginAsset' => YII_PATH . '/bootstrap/BootstrapPluginAsset.php', 'yii\bootstrap\Button' => YII_PATH . '/bootstrap/Button.php', - 'yii\bootstrap\ButtonAsset' => YII_PATH . '/bootstrap/ButtonAsset.php', 'yii\bootstrap\ButtonDropdown' => YII_PATH . '/bootstrap/ButtonDropdown.php', 'yii\bootstrap\ButtonGroup' => YII_PATH . '/bootstrap/ButtonGroup.php', 'yii\bootstrap\Carousel' => YII_PATH . '/bootstrap/Carousel.php', - 'yii\bootstrap\CarouselAsset' => YII_PATH . '/bootstrap/CarouselAsset.php', 'yii\bootstrap\Collapse' => YII_PATH . '/bootstrap/Collapse.php', - 'yii\bootstrap\CollapseAsset' => YII_PATH . '/bootstrap/CollapseAsset.php', 'yii\bootstrap\Dropdown' => YII_PATH . '/bootstrap/Dropdown.php', - 'yii\bootstrap\DropdownAsset' => YII_PATH . '/bootstrap/DropdownAsset.php', 'yii\bootstrap\Modal' => YII_PATH . '/bootstrap/Modal.php', - 'yii\bootstrap\ModalAsset' => YII_PATH . '/bootstrap/ModalAsset.php', 'yii\bootstrap\Nav' => YII_PATH . '/bootstrap/Nav.php', 'yii\bootstrap\NavBar' => YII_PATH . '/bootstrap/NavBar.php', - 'yii\bootstrap\PopoverAsset' => YII_PATH . '/bootstrap/PopoverAsset.php', 'yii\bootstrap\Progress' => YII_PATH . '/bootstrap/Progress.php', - 'yii\bootstrap\ResponsiveAsset' => YII_PATH . '/bootstrap/ResponsiveAsset.php', - 'yii\bootstrap\ScrollspyAsset' => YII_PATH . '/bootstrap/ScrollspyAsset.php', - 'yii\bootstrap\TabAsset' => YII_PATH . '/bootstrap/TabAsset.php', 'yii\bootstrap\Tabs' => YII_PATH . '/bootstrap/Tabs.php', - 'yii\bootstrap\TooltipAsset' => YII_PATH . '/bootstrap/TooltipAsset.php', - 'yii\bootstrap\TransitionAsset' => YII_PATH . '/bootstrap/TransitionAsset.php', 'yii\bootstrap\Typeahead' => YII_PATH . '/bootstrap/Typeahead.php', - 'yii\bootstrap\TypeaheadAsset' => YII_PATH . '/bootstrap/TypeaheadAsset.php', 'yii\bootstrap\Widget' => YII_PATH . '/bootstrap/Widget.php', 'yii\caching\ApcCache' => YII_PATH . '/caching/ApcCache.php', 'yii\caching\Cache' => YII_PATH . '/caching/Cache.php', @@ -110,6 +98,12 @@ return array( 'yii\db\Exception' => YII_PATH . '/db/Exception.php', 'yii\db\Expression' => YII_PATH . '/db/Expression.php', 'yii\db\Migration' => YII_PATH . '/db/Migration.php', + 'yii\db\Query' => YII_PATH . '/db/Query.php', + 'yii\db\QueryBuilder' => YII_PATH . '/db/QueryBuilder.php', + 'yii\db\Schema' => YII_PATH . '/db/Schema.php', + 'yii\db\StaleObjectException' => YII_PATH . '/db/StaleObjectException.php', + 'yii\db\TableSchema' => YII_PATH . '/db/TableSchema.php', + 'yii\db\Transaction' => YII_PATH . '/db/Transaction.php', 'yii\db\mssql\PDO' => YII_PATH . '/db/mssql/PDO.php', 'yii\db\mssql\QueryBuilder' => YII_PATH . '/db/mssql/QueryBuilder.php', 'yii\db\mssql\Schema' => YII_PATH . '/db/mssql/Schema.php', @@ -118,14 +112,14 @@ return array( 'yii\db\mysql\Schema' => YII_PATH . '/db/mysql/Schema.php', 'yii\db\pgsql\QueryBuilder' => YII_PATH . '/db/pgsql/QueryBuilder.php', 'yii\db\pgsql\Schema' => YII_PATH . '/db/pgsql/Schema.php', - 'yii\db\Query' => YII_PATH . '/db/Query.php', - 'yii\db\QueryBuilder' => YII_PATH . '/db/QueryBuilder.php', - 'yii\db\Schema' => YII_PATH . '/db/Schema.php', 'yii\db\sqlite\QueryBuilder' => YII_PATH . '/db/sqlite/QueryBuilder.php', 'yii\db\sqlite\Schema' => YII_PATH . '/db/sqlite/Schema.php', - 'yii\db\StaleObjectException' => YII_PATH . '/db/StaleObjectException.php', - 'yii\db\TableSchema' => YII_PATH . '/db/TableSchema.php', - 'yii\db\Transaction' => YII_PATH . '/db/Transaction.php', + 'yii\grid\CheckboxColumn' => YII_PATH . '/grid/CheckboxColumn.php', + 'yii\grid\Column' => YII_PATH . '/grid/Column.php', + 'yii\grid\DataColumn' => YII_PATH . '/grid/DataColumn.php', + 'yii\grid\GridView' => YII_PATH . '/grid/GridView.php', + 'yii\grid\GridViewAsset' => YII_PATH . '/grid/GridViewAsset.php', + 'yii\grid\SerialColumn' => YII_PATH . '/grid/SerialColumn.php', 'yii\helpers\ArrayHelper' => YII_PATH . '/helpers/ArrayHelper.php', 'yii\helpers\ArrayHelperBase' => YII_PATH . '/helpers/ArrayHelperBase.php', 'yii\helpers\Console' => YII_PATH . '/helpers/Console.php', @@ -199,6 +193,7 @@ return array( 'yii\web\Cookie' => YII_PATH . '/web/Cookie.php', 'yii\web\CookieCollection' => YII_PATH . '/web/CookieCollection.php', 'yii\web\DbSession' => YII_PATH . '/web/DbSession.php', + 'yii\web\ErrorAction' => YII_PATH . '/web/ErrorAction.php', 'yii\web\HeaderCollection' => YII_PATH . '/web/HeaderCollection.php', 'yii\web\HttpCache' => YII_PATH . '/web/HttpCache.php', 'yii\web\HttpException' => YII_PATH . '/web/HttpException.php', @@ -229,10 +224,6 @@ return array( 'yii\widgets\ContentDecorator' => YII_PATH . '/widgets/ContentDecorator.php', 'yii\widgets\DetailView' => YII_PATH . '/widgets/DetailView.php', 'yii\widgets\FragmentCache' => YII_PATH . '/widgets/FragmentCache.php', - 'yii\grid\CheckboxColumn' => YII_PATH . '/grid/CheckboxColumn.php', - 'yii\grid\Column' => YII_PATH . '/grid/Column.php', - 'yii\grid\DataColumn' => YII_PATH . '/grid/DataColumn.php', - 'yii\grid\GridView' => YII_PATH . '/grid/GridView.php', 'yii\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php', 'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php', 'yii\widgets\LinkSorter' => YII_PATH . '/widgets/LinkSorter.php',