From 5f2a612c78f60081e5d2323fd0a413c7ca8deaa3 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 4 Dec 2013 09:48:01 +0100 Subject: [PATCH] Moved file and path related methods from StringHelper to FileHelper, renamed StringHelper byte methods not to be misused as string methods --- extensions/elasticsearch/ActiveRecord.php | 8 +-- .../gii/generators/crud/templates/controller.php | 12 ++-- .../gii/generators/crud/templates/search.php | 8 +-- .../gii/generators/crud/templates/views/_form.php | 4 +- .../generators/crud/templates/views/_search.php | 4 +- .../gii/generators/crud/templates/views/create.php | 8 +-- .../gii/generators/crud/templates/views/index.php | 8 +-- .../gii/generators/crud/templates/views/update.php | 8 +-- .../gii/generators/crud/templates/views/view.php | 6 +- extensions/gii/generators/module/Generator.php | 4 +- extensions/redis/ActiveRecord.php | 6 +- extensions/sphinx/ActiveRecord.php | 4 +- framework/yii/caching/Cache.php | 2 +- framework/yii/db/ActiveRecord.php | 9 +-- framework/yii/helpers/BaseFileHelper.php | 50 ++++++++++++++++- framework/yii/helpers/BaseSecurity.php | 22 ++++---- framework/yii/helpers/BaseStringHelper.php | 45 +-------------- framework/yii/web/Response.php | 6 +- framework/yii/web/XmlResponseFormatter.php | 4 +- tests/unit/framework/helpers/StringHelperTest.php | 65 +++++++++++----------- tests/unit/framework/web/ResponseTest.php | 2 +- 21 files changed, 141 insertions(+), 144 deletions(-) diff --git a/extensions/elasticsearch/ActiveRecord.php b/extensions/elasticsearch/ActiveRecord.php index d6ada20..e6e28b7 100644 --- a/extensions/elasticsearch/ActiveRecord.php +++ b/extensions/elasticsearch/ActiveRecord.php @@ -9,12 +9,10 @@ namespace yii\elasticsearch; use yii\base\InvalidCallException; use yii\base\InvalidConfigException; -use yii\base\NotSupportedException; -use yii\db\ActiveRecordInterface; use yii\db\BaseActiveRecord; +use yii\helpers\FileHelper; use yii\helpers\Inflector; use yii\helpers\Json; -use yii\helpers\StringHelper; /** * ActiveRecord is the base class for classes representing relational data in terms of objects. @@ -228,7 +226,7 @@ class ActiveRecord extends BaseActiveRecord */ public static function index() { - return Inflector::pluralize(Inflector::camel2id(StringHelper::basename(get_called_class()), '-')); + return Inflector::pluralize(Inflector::camel2id(FileHelper::basename(get_called_class()), '-')); } /** @@ -236,7 +234,7 @@ class ActiveRecord extends BaseActiveRecord */ public static function type() { - return Inflector::camel2id(StringHelper::basename(get_called_class()), '-'); + return Inflector::camel2id(FileHelper::basename(get_called_class()), '-'); } /** diff --git a/extensions/gii/generators/crud/templates/controller.php b/extensions/gii/generators/crud/templates/controller.php index bb5d3f4..c1ce71f 100644 --- a/extensions/gii/generators/crud/templates/controller.php +++ b/extensions/gii/generators/crud/templates/controller.php @@ -1,7 +1,7 @@ controllerClass); -$modelClass = StringHelper::basename($generator->modelClass); -$searchModelClass = StringHelper::basename($generator->searchModelClass); +$controllerClass = FileHelper::basename($generator->controllerClass); +$modelClass = FileHelper::basename($generator->modelClass); +$searchModelClass = FileHelper::basename($generator->searchModelClass); if ($modelClass === $searchModelClass) { $searchModelAlias = $searchModelClass.'Search'; } @@ -27,7 +27,7 @@ $actionParamComments = $generator->generateActionParamComments(); echo " -namespace controllerClass, '\\')) ?>; +namespace controllerClass, '\\')) ?>; use modelClass, '\\') ?>; use searchModelClass, '\\') ?> as ; @@ -38,7 +38,7 @@ use yii\web\VerbFilter; /** * implements the CRUD actions for model. */ -class extends baseControllerClass) . "\n" ?> +class extends baseControllerClass) . "\n" ?> { public function behaviors() { diff --git a/extensions/gii/generators/crud/templates/search.php b/extensions/gii/generators/crud/templates/search.php index 1411896..1a9da82 100644 --- a/extensions/gii/generators/crud/templates/search.php +++ b/extensions/gii/generators/crud/templates/search.php @@ -1,6 +1,6 @@ modelClass); -$searchModelClass = StringHelper::basename($generator->searchModelClass); +$modelClass = FileHelper::basename($generator->modelClass); +$searchModelClass = FileHelper::basename($generator->searchModelClass); $rules = $generator->generateSearchRules(); $labels = $generator->generateSearchLabels(); $searchAttributes = $generator->getSearchAttributes(); @@ -19,7 +19,7 @@ $searchConditions = $generator->generateSearchConditions(); echo " -namespace searchModelClass, '\\')) ?>; +namespace searchModelClass, '\\')) ?>; use yii\base\Model; use yii\data\ActiveDataProvider; diff --git a/extensions/gii/generators/crud/templates/views/_form.php b/extensions/gii/generators/crud/templates/views/_form.php index 52538d5..4ac7971 100644 --- a/extensions/gii/generators/crud/templates/views/_form.php +++ b/extensions/gii/generators/crud/templates/views/_form.php @@ -1,7 +1,7 @@ -
+
$form = ActiveForm::begin(); ?> diff --git a/extensions/gii/generators/crud/templates/views/_search.php b/extensions/gii/generators/crud/templates/views/_search.php index af2f948..6ba9ee0 100644 --- a/extensions/gii/generators/crud/templates/views/_search.php +++ b/extensions/gii/generators/crud/templates/views/_search.php @@ -1,7 +1,7 @@ -