Commit a6cd7b72 by Qiang Xue

refactored helper organization.

parent 7ebbc46a
......@@ -2,7 +2,7 @@
namespace common\models;
use yii\db\ActiveRecord;
use yii\helpers\SecurityHelper;
use yii\helpers\Security;
use yii\web\Identity;
/**
......@@ -72,7 +72,7 @@ class User extends ActiveRecord implements Identity
public function validatePassword($password)
{
return SecurityHelper::validatePassword($password, $this->password_hash);
return Security::validatePassword($password, $this->password_hash);
}
public function rules()
......@@ -105,10 +105,10 @@ class User extends ActiveRecord implements Identity
{
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;
}
......
......@@ -4,7 +4,7 @@ namespace frontend\models;
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.
......@@ -33,7 +33,7 @@ class SendPasswordResetTokenForm extends Model
'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,
......
......@@ -46,19 +46,34 @@ 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\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',
......@@ -109,27 +124,27 @@ return array(
'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',
......@@ -162,12 +177,14 @@ return array(
'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',
......@@ -186,6 +203,7 @@ return array(
'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',
......@@ -201,20 +219,22 @@ return array(
'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',
);
......@@ -137,7 +137,7 @@ class Controller extends \yii\base\Controller
/**
* 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:
*
......@@ -162,7 +162,7 @@ class Controller extends \yii\base\Controller
* 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:
*
......@@ -187,7 +187,7 @@ class Controller extends \yii\base\Controller
* 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:
*
......
......@@ -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 <qiang.xue@gmail.com>
* @since 2.0
*/
class ArrayHelper extends base\ArrayHelper
class ArrayHelper extends ArrayHelperBase
{
}
......@@ -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 <qiang.xue@gmail.com>
* @since 2.0
*/
class ArrayHelper
class ArrayHelperBase
{
/**
* Converts an object or an array of objects into an array.
......
......@@ -17,6 +17,6 @@ namespace yii\helpers;
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class Console extends base\Console
class Console extends ConsoleBase
{
}
......@@ -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 <mail@cebe.cc>
* @since 2.0
*/
class Console
class ConsoleBase
{
const FG_BLACK = 30;
const FG_RED = 31;
......
......@@ -16,6 +16,6 @@ namespace yii\helpers;
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class FileHelper extends base\FileHelper
class FileHelper extends FileHelperBase
{
}
......@@ -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 <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class FileHelper
class FileHelperBase
{
/**
* Normalizes a file/directory path.
......@@ -279,11 +280,11 @@ class FileHelper
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;
}
}
......@@ -291,7 +292,7 @@ class FileHelper
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;
}
}
......
......@@ -13,6 +13,6 @@ namespace yii\helpers;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class Html extends base\Html
class Html extends HtmlBase
{
}
......@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
use Yii;
use yii\base\InvalidParamException;
......@@ -13,12 +13,14 @@ 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 <qiang.xue@gmail.com>
* @since 2.0
*/
class Html
class HtmlBase
{
/**
* @var array list of void elements (element name => 1)
......
......@@ -32,6 +32,6 @@ namespace yii\helpers;
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class HtmlPurifier extends base\HtmlPurifier
class HtmlPurifier extends HtmlPurifierBase
{
}
......@@ -4,17 +4,17 @@
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
/**
* HtmlPurifier is the concrete implementation of the [[yii\helpers\HtmlPurifier]] class.
* HtmlPurifierBase provides concrete implementation for [[HtmlPurifier]].
*
* You should use [[yii\helpers\HtmlPurifier]] instead of this class in your application.
* Do not use HtmlPurifierBase. Use [[HtmlPurifier]] instead.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class HtmlPurifier
class HtmlPurifierBase
{
/**
* Passes markup through HTMLPurifier making it safe to output to end user
......
......@@ -13,6 +13,6 @@ namespace yii\helpers;
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class Inflector extends base\Inflector
class Inflector extends InflectorBase
{
}
......@@ -5,17 +5,19 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
use Yii;
/**
* Inflector pluralizes and singularizes English nouns. It also contains some other useful methods.
* InflectorBase provides concrete implementation for [[Inflector]].
*
* Do not use InflectorBase. Use [[Inflector]] instead.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class Inflector
class InflectorBase
{
/**
* @var array the rules for converting a word into its plural form.
......
......@@ -8,10 +8,12 @@
namespace yii\helpers;
/**
*
* Json is a helper class providing JSON data encoding and decoding.
* It enhances the PHP built-in functions `json_encode()` and `json_decode()`
* by supporting encoding JavaScript expressions and throwing exceptions when decoding fails.
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class Json extends base\Json
class Json extends JsonBase
{
}
......@@ -5,20 +5,21 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
use yii\base\InvalidParamException;
use yii\base\Arrayable;
use yii\web\JsExpression;
/**
* Json is a helper class providing JSON data encoding and decoding.
* It enhances the PHP built-in functions `json_encode()` and `json_decode()`
* by supporting encoding JavaScript expressions and throwing exceptions when decoding fails.
* JsonBase provides concrete implementation for [[Json]].
*
* Do not use JsonBase. Use [[Json]] instead.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class Json
class JsonBase
{
/**
* Encodes the given value into a JSON string.
......
......@@ -28,6 +28,6 @@ namespace yii\helpers;
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Markdown extends base\Markdown
class Markdown extends MarkdownBase
{
}
......@@ -5,32 +5,19 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
use Michelf\MarkdownExtra;
/**
* Markdown provides an ability to transform markdown into HTML.
* MarkdownBase provides concrete implementation for [[Markdown]].
*
* Basic usage is the following:
* Do not use MarkdownBase. Use [[Markdown]] instead.
*
* ```php
* $myHtml = Markdown::process($myText);
* ```
*
* If you want to configure the parser:
*
* ```php
* $myHtml = Markdown::process($myText, array(
* 'fn_id_prefix' => 'footnote_',
* ));
* ```
*
* For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/).
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Markdown
class MarkdownBase
{
/**
* @var MarkdownExtra
......
......@@ -8,15 +8,15 @@
namespace yii\helpers;
/**
* SecurityHelper provides a set of methods to handle common security-related tasks.
* Security provides a set of methods to handle common security-related tasks.
*
* In particular, SecurityHelper supports the following features:
* In particular, Security supports the following features:
*
* - Encryption/decryption: [[encrypt()]] and [[decrypt()]]
* - Data tampering prevention: [[hashData()]] and [[validateData()]]
* - Password validation: [[generatePasswordHash()]] and [[validatePassword()]]
*
* Additionally, SecurityHelper provides [[getSecretKey()]] to support generating
* Additionally, Security provides [[getSecretKey()]] to support generating
* named secret keys. These secret keys, once generated, will be stored in a file
* and made available in future requests.
*
......@@ -24,6 +24,6 @@ namespace yii\helpers;
* @author Tom Worster <fsb@thefsb.org>
* @since 2.0
*/
class SecurityHelper extends base\SecurityHelper
class Security extends SecurityBase
{
}
......@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
use Yii;
use yii\base\Exception;
......@@ -13,23 +13,15 @@ use yii\base\InvalidConfigException;
use yii\base\InvalidParamException;
/**
* SecurityHelper provides a set of methods to handle common security-related tasks.
* SecurityBase provides concrete implementation for [[Security]].
*
* In particular, SecurityHelper supports the following features:
*
* - Encryption/decryption: [[encrypt()]] and [[decrypt()]]
* - Data tampering prevention: [[hashData()]] and [[validateData()]]
* - Password validation: [[generatePasswordHash()]] and [[validatePassword()]]
*
* Additionally, SecurityHelper provides [[getSecretKey()]] to support generating
* named secret keys. These secret keys, once generated, will be stored in a file
* and made available in future requests.
* Do not use SecurityBase. Use [[Security]] instead.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Tom Worster <fsb@thefsb.org>
* @since 2.0
*/
class SecurityHelper
class SecurityBase
{
/**
* Encrypts data.
......@@ -182,11 +174,11 @@ class SecurityHelper
*
* ~~~
* // generates the hash (usually done during user registration or when the password is changed)
* $hash = SecurityHelper::generatePasswordHash($password);
* $hash = Security::generatePasswordHash($password);
* // ...save $hash in database...
*
* // during login, validate if the password entered is correct using $hash fetched from database
* if (SecurityHelper::validatePassword($password, $hash) {
* if (Security::validatePassword($password, $hash) {
* // password is good
* } else {
* // password is bad
......
......@@ -14,6 +14,6 @@ namespace yii\helpers;
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class StringHelper extends base\StringHelper
class StringHelper extends StringHelperBase
{
}
......@@ -5,16 +5,18 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
/**
* StringHelper
* StringHelperBase provides concrete implementation for [[StringHelper]].
*
* Do not use StringHelperBase. Use [[StringHelper]] instead.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alex Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class StringHelper
class StringHelperBase
{
/**
* Returns the number of bytes in the given string.
......
......@@ -23,6 +23,6 @@ namespace yii\helpers;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class VarDumper extends base\VarDumper
class VarDumper extends VarDumperBase
{
}
......@@ -6,24 +6,17 @@
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
namespace yii\helpers;
/**
* VarDumper is intended to replace the buggy PHP function var_dump and print_r.
* It can correctly identify the recursively referenced objects in a complex
* object structure. It also has a recursive depth control to avoid indefinite
* recursive display of some peculiar variables.
* VarDumperBase provides concrete implementation for [[VarDumper]].
*
* VarDumper can be used as follows,
*
* ~~~
* VarDumper::dump($var);
* ~~~
* Do not use VarDumperBase. Use [[VarDumper]] instead.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class VarDumper
class VarDumperBase
{
private static $_objects;
private static $_output;
......
......@@ -9,7 +9,7 @@ namespace yii\web;
use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\SecurityHelper;
use yii\helpers\Security;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
......@@ -823,7 +823,7 @@ class Request extends \yii\base\Request
if ($this->enableCookieValidation) {
$key = $this->getCookieValidationKey();
foreach ($_COOKIE as $name => $value) {
if (is_string($value) && ($value = SecurityHelper::validateData($value, $key)) !== false) {
if (is_string($value) && ($value = Security::validateData($value, $key)) !== false) {
$cookies[$name] = new Cookie(array(
'name' => $name,
'value' => @unserialize($value),
......@@ -850,7 +850,7 @@ class Request extends \yii\base\Request
public function getCookieValidationKey()
{
if ($this->_cookieValidationKey === null) {
$this->_cookieValidationKey = SecurityHelper::getSecretKey(__CLASS__ . '/' . Yii::$app->id);
$this->_cookieValidationKey = Security::getSecretKey(__CLASS__ . '/' . Yii::$app->id);
}
return $this->_cookieValidationKey;
}
......
......@@ -13,7 +13,7 @@ use yii\base\InvalidParamException;
use yii\helpers\FileHelper;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\SecurityHelper;
use yii\helpers\Security;
use yii\helpers\StringHelper;
/**
......@@ -313,7 +313,7 @@ class Response extends \yii\base\Response
foreach ($this->getCookies() as $cookie) {
$value = $cookie->value;
if ($cookie->expire != 1 && isset($validationKey)) {
$value = SecurityHelper::hashData(serialize($value), $validationKey);
$value = Security::hashData(serialize($value), $validationKey);
}
setcookie($cookie->name, $value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httpOnly);
}
......
......@@ -4,7 +4,7 @@ use yii\helpers\FileHelper;
use yii\test\TestCase;
/**
* Unit test for [[yii\helpers\base\FileHelper]]
* Unit test for [[yii\helpers\FileHelper]]
* @see FileHelper
*/
class FileHelperTest extends TestCase
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment