Skip to content

Commit

Permalink
refactored helper organization.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiangxue committed Jul 18, 2013
1 parent 7ebbc46 commit a6cd7b7
Show file tree
Hide file tree
Showing 30 changed files with 124 additions and 131 deletions.
8 changes: 4 additions & 4 deletions apps/advanced/common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace common\models;

use yii\db\ActiveRecord;
use yii\helpers\SecurityHelper;
use yii\helpers\Security;
use yii\web\Identity;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ public function validateAuthKey($authKey)

public function validatePassword($password)
{
return SecurityHelper::validatePassword($password, $this->password_hash);
return Security::validatePassword($password, $this->password_hash);
}

public function rules()
Expand Down Expand Up @@ -105,10 +105,10 @@ public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if (($this->isNewRecord || $this->getScenario() === 'resetPassword') && !empty($this->password)) {
$this->password_hash = SecurityHelper::generatePasswordHash($this->password);
$this->password_hash = Security::generatePasswordHash($this->password);
}
if ($this->isNewRecord) {
$this->auth_key = SecurityHelper::generateRandomKey();
$this->auth_key = Security::generateRandomKey();
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/advanced/frontend/models/SendPasswordResetTokenForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use yii\base\Model;
use common\models\User;
use yii\base\View;
use yii\helpers\SecurityHelper;
use yii\helpers\Security;

/**
* SendPasswordResetTokenForm is the model behind requesting password reset token form.
Expand Down Expand Up @@ -33,7 +33,7 @@ public function sendEmail()
'status' => User::STATUS_ACTIVE,
));
if ($user) {
$user->password_reset_token = SecurityHelper::generateRandomKey();
$user->password_reset_token = Security::generateRandomKey();
if ($user->save(false)) {
$view = new View(array(
'context' => \Yii::$app->controller,
Expand Down
50 changes: 35 additions & 15 deletions framework/yii/classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,34 @@
'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\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\TypeAhead' => YII_PATH . '/bootstrap/TypeAhead.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',
Expand Down Expand Up @@ -109,27 +124,27 @@
'yii\db\TableSchema' => YII_PATH . '/db/TableSchema.php',
'yii\db\Transaction' => YII_PATH . '/db/Transaction.php',
'yii\helpers\ArrayHelper' => YII_PATH . '/helpers/ArrayHelper.php',
'yii\helpers\base\ArrayHelper' => YII_PATH . '/helpers/base/ArrayHelper.php',
'yii\helpers\base\Console' => YII_PATH . '/helpers/base/Console.php',
'yii\helpers\base\FileHelper' => YII_PATH . '/helpers/base/FileHelper.php',
'yii\helpers\base\Html' => YII_PATH . '/helpers/base/Html.php',
'yii\helpers\base\HtmlPurifier' => YII_PATH . '/helpers/base/HtmlPurifier.php',
'yii\helpers\base\Inflector' => YII_PATH . '/helpers/base/Inflector.php',
'yii\helpers\base\Json' => YII_PATH . '/helpers/base/Json.php',
'yii\helpers\base\Markdown' => YII_PATH . '/helpers/base/Markdown.php',
'yii\helpers\base\SecurityHelper' => YII_PATH . '/helpers/base/SecurityHelper.php',
'yii\helpers\base\StringHelper' => YII_PATH . '/helpers/base/StringHelper.php',
'yii\helpers\base\VarDumper' => YII_PATH . '/helpers/base/VarDumper.php',
'yii\helpers\ArrayHelperBase' => YII_PATH . '/helpers/ArrayHelperBase.php',
'yii\helpers\Console' => YII_PATH . '/helpers/Console.php',
'yii\helpers\ConsoleBase' => YII_PATH . '/helpers/ConsoleBase.php',
'yii\helpers\FileHelper' => YII_PATH . '/helpers/FileHelper.php',
'yii\helpers\FileHelperBase' => YII_PATH . '/helpers/FileHelperBase.php',
'yii\helpers\Html' => YII_PATH . '/helpers/Html.php',
'yii\helpers\HtmlBase' => YII_PATH . '/helpers/HtmlBase.php',
'yii\helpers\HtmlPurifier' => YII_PATH . '/helpers/HtmlPurifier.php',
'yii\helpers\HtmlPurifierBase' => YII_PATH . '/helpers/HtmlPurifierBase.php',
'yii\helpers\Inflector' => YII_PATH . '/helpers/Inflector.php',
'yii\helpers\InflectorBase' => YII_PATH . '/helpers/InflectorBase.php',
'yii\helpers\Json' => YII_PATH . '/helpers/Json.php',
'yii\helpers\JsonBase' => YII_PATH . '/helpers/JsonBase.php',
'yii\helpers\Markdown' => YII_PATH . '/helpers/Markdown.php',
'yii\helpers\SecurityHelper' => YII_PATH . '/helpers/SecurityHelper.php',
'yii\helpers\MarkdownBase' => YII_PATH . '/helpers/MarkdownBase.php',
'yii\helpers\Security' => YII_PATH . '/helpers/Security.php',
'yii\helpers\SecurityBase' => YII_PATH . '/helpers/SecurityBase.php',
'yii\helpers\StringHelper' => YII_PATH . '/helpers/StringHelper.php',
'yii\helpers\StringHelperBase' => YII_PATH . '/helpers/StringHelperBase.php',
'yii\helpers\VarDumper' => YII_PATH . '/helpers/VarDumper.php',
'yii\helpers\VarDumperBase' => YII_PATH . '/helpers/VarDumperBase.php',
'yii\i18n\DbMessageSource' => YII_PATH . '/i18n/DbMessageSource.php',
'yii\i18n\Formatter' => YII_PATH . '/i18n/Formatter.php',
'yii\i18n\GettextFile' => YII_PATH . '/i18n/GettextFile.php',
Expand Down Expand Up @@ -162,12 +177,14 @@
'yii\validators\FilterValidator' => YII_PATH . '/validators/FilterValidator.php',
'yii\validators\InlineValidator' => YII_PATH . '/validators/InlineValidator.php',
'yii\validators\NumberValidator' => YII_PATH . '/validators/NumberValidator.php',
'yii\validators\PunycodeAsset' => YII_PATH . '/validators/PunycodeAsset.php',
'yii\validators\RangeValidator' => YII_PATH . '/validators/RangeValidator.php',
'yii\validators\RegularExpressionValidator' => YII_PATH . '/validators/RegularExpressionValidator.php',
'yii\validators\RequiredValidator' => YII_PATH . '/validators/RequiredValidator.php',
'yii\validators\StringValidator' => YII_PATH . '/validators/StringValidator.php',
'yii\validators\UniqueValidator' => YII_PATH . '/validators/UniqueValidator.php',
'yii\validators\UrlValidator' => YII_PATH . '/validators/UrlValidator.php',
'yii\validators\ValidationAsset' => YII_PATH . '/validators/ValidationAsset.php',
'yii\validators\Validator' => YII_PATH . '/validators/Validator.php',
'yii\web\AccessControl' => YII_PATH . '/web/AccessControl.php',
'yii\web\AccessRule' => YII_PATH . '/web/AccessRule.php',
Expand All @@ -186,6 +203,7 @@
'yii\web\HttpException' => YII_PATH . '/web/HttpException.php',
'yii\web\IAssetConverter' => YII_PATH . '/web/IAssetConverter.php',
'yii\web\Identity' => YII_PATH . '/web/Identity.php',
'yii\web\JqueryAsset' => YII_PATH . '/web/JqueryAsset.php',
'yii\web\JsExpression' => YII_PATH . '/web/JsExpression.php',
'yii\web\PageCache' => YII_PATH . '/web/PageCache.php',
'yii\web\Request' => YII_PATH . '/web/Request.php',
Expand All @@ -201,20 +219,22 @@
'yii\web\UserEvent' => YII_PATH . '/web/UserEvent.php',
'yii\web\VerbFilter' => YII_PATH . '/web/VerbFilter.php',
'yii\web\XmlResponseFormatter' => YII_PATH . '/web/XmlResponseFormatter.php',
'yii\web\YiiAsset' => YII_PATH . '/web/YiiAsset.php',
'yii\widgets\ActiveField' => YII_PATH . '/widgets/ActiveField.php',
'yii\widgets\ActiveForm' => YII_PATH . '/widgets/ActiveForm.php',
'yii\widgets\BaseListView' => YII_PATH . '/widgets/BaseListView.php',
'yii\widgets\ActiveFormAsset' => YII_PATH . '/widgets/ActiveFormAsset.php',
'yii\widgets\Block' => YII_PATH . '/widgets/Block.php',
'yii\widgets\Breadcrumbs' => YII_PATH . '/widgets/Breadcrumbs.php',
'yii\widgets\Captcha' => YII_PATH . '/widgets/Captcha.php',
'yii\widgets\CaptchaAsset' => YII_PATH . '/widgets/CaptchaAsset.php',
'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\widgets\InputWidget' => YII_PATH . '/widgets/InputWidget.php',
'yii\widgets\LinkPager' => YII_PATH . '/widgets/LinkPager.php',
'yii\widgets\ListPager' => YII_PATH . '/widgets/ListPager.php',
'yii\widgets\ListView' => YII_PATH . '/widgets/ListView.php',
'yii\widgets\MaskedInput' => YII_PATH . '/widgets/MaskedInput.php',
'yii\widgets\MaskedInputAsset' => YII_PATH . '/widgets/MaskedInputAsset.php',
'yii\widgets\Menu' => YII_PATH . '/widgets/Menu.php',
'yii\widgets\Spaceless' => YII_PATH . '/widgets/Spaceless.php',
);
6 changes: 3 additions & 3 deletions framework/yii/console/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function bindActionParams($action, $params)
/**
* Formats a string with ANSI codes
*
* You may pass additional parameters using the constants defined in [[yii\helpers\base\Console]].
* You may pass additional parameters using the constants defined in [[yii\helpers\Console]].
*
* Example:
*
Expand All @@ -162,7 +162,7 @@ public function ansiFormat($string)
* Prints a string to STDOUT
*
* You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[yii\helpers\base\Console]].
* passing additional parameters using the constants defined in [[yii\helpers\Console]].
*
* Example:
*
Expand All @@ -187,7 +187,7 @@ public function stdout($string)
* Prints a string to STDERR
*
* You may optionally format the string with ANSI codes by
* passing additional parameters using the constants defined in [[yii\helpers\base\Console]].
* passing additional parameters using the constants defined in [[yii\helpers\Console]].
*
* Example:
*
Expand Down
4 changes: 2 additions & 2 deletions framework/yii/helpers/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
namespace yii\helpers;

/**
* ArrayHelper provides additional array functionality you can use in your
* ArrayHelper provides additional array functionality that you can use in your
* application.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class ArrayHelper extends base\ArrayHelper
class ArrayHelper extends ArrayHelperBase
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
* @license http://www.yiiframework.com/license/
*/

namespace yii\helpers\base;
namespace yii\helpers;

use Yii;
use yii\base\Arrayable;
use yii\base\InvalidParamException;

/**
* ArrayHelper provides additional array functionality you can use in your
* application.
* ArrayHelperBase provides concrete implementation for [[ArrayHelper]].
*
* Do not use ArrayHelperBase. Use [[ArrayHelper]] instead.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class ArrayHelper
class ArrayHelperBase
{
/**
* Converts an object or an array of objects into an array.
Expand Down
2 changes: 1 addition & 1 deletion framework/yii/helpers/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* @author Carsten Brandt <[email protected]>
* @since 2.0
*/
class Console extends base\Console
class Console extends ConsoleBase
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,17 @@
* @license http://www.yiiframework.com/license/
*/

namespace yii\helpers\base;
namespace yii\helpers;

/**
* TODO adjust phpdoc
* TODO test this on all kinds of terminals, especially windows (check out lib ncurses)
*
* Console View is the base class for console view components
*
* A console view provides functionality to create rich console application by allowing to format output
* by adding color and font style to it.
*
* The following constants are available for formatting:
*
* TODO document constants
*
* ConsoleBase provides concrete implementation for [[Console]].
*
* Do not use ConsoleBase. Use [[Console]] instead.
*
* @author Carsten Brandt <[email protected]>
* @since 2.0
*/
class Console
class ConsoleBase
{
const FG_BLACK = 30;
const FG_RED = 31;
Expand Down
2 changes: 1 addition & 1 deletion framework/yii/helpers/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
* @author Alex Makarov <[email protected]>
* @since 2.0
*/
class FileHelper extends base\FileHelper
class FileHelper extends FileHelperBase
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
* @license http://www.yiiframework.com/license/
*/

namespace yii\helpers\base;
namespace yii\helpers;

use Yii;
use yii\helpers\StringHelper as StringHelper2;

/**
* Filesystem helper
* FileHelperBase provides concrete implementation for [[FileHelper]].
*
* Do not use FileHelperBase. Use [[FileHelper]] instead.
*
* @author Qiang Xue <[email protected]>
* @author Alex Makarov <[email protected]>
* @since 2.0
*/
class FileHelper
class FileHelperBase
{
/**
* Normalizes a file/directory path.
Expand Down Expand Up @@ -279,19 +280,19 @@ public static function filterPath($path, $options)
if ($isDir = is_dir($path)) {
$path .= '/';
}
$n = StringHelper2::strlen($path);
$n = StringHelper::strlen($path);

if (!empty($options['except'])) {
foreach ($options['except'] as $name) {
if (StringHelper2::substr($path, -StringHelper2::strlen($name), $n) === $name) {
if (StringHelper::substr($path, -StringHelper::strlen($name), $n) === $name) {
return false;
}
}
}

if (!$isDir && !empty($options['only'])) {
foreach ($options['only'] as $name) {
if (StringHelper2::substr($path, -StringHelper2::strlen($name), $n) === $name) {
if (StringHelper::substr($path, -StringHelper::strlen($name), $n) === $name) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion framework/yii/helpers/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class Html extends base\Html
class Html extends HtmlBase
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
* @license http://www.yiiframework.com/license/
*/

namespace yii\helpers\base;
namespace yii\helpers;

use Yii;
use yii\base\InvalidParamException;
use yii\web\Request;
use yii\base\Model;

/**
* Html provides a set of static methods for generating commonly used HTML tags.
* HtmlBase provides concrete implementation for [[Html]].
*
* Do not use HtmlBase. Use [[Html]] instead.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class Html
class HtmlBase
{
/**
* @var array list of void elements (element name => 1)
Expand Down
2 changes: 1 addition & 1 deletion framework/yii/helpers/HtmlPurifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* @author Alexander Makarov <[email protected]>
* @since 2.0
*/
class HtmlPurifier extends base\HtmlPurifier
class HtmlPurifier extends HtmlPurifierBase
{
}
Loading

0 comments on commit a6cd7b7

Please sign in to comment.