mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Merge master into doc-fixes
Conflicts: framework/web/AssetManager.php
This commit is contained in:
@ -13,7 +13,7 @@ use Yii;
|
|||||||
* Component is the base class that implements the *property*, *event* and *behavior* features.
|
* Component is the base class that implements the *property*, *event* and *behavior* features.
|
||||||
*
|
*
|
||||||
* Component provides the *event* and *behavior* features, in addition to the *property* feature which is implemented in
|
* Component provides the *event* and *behavior* features, in addition to the *property* feature which is implemented in
|
||||||
* its parent class [[Object]].
|
* its parent class [[\yii\base\Object|Object]].
|
||||||
*
|
*
|
||||||
* Event is a way to "inject" custom code into existing code at certain places. For example, a comment object can trigger
|
* Event is a way to "inject" custom code into existing code at certain places. For example, a comment object can trigger
|
||||||
* an "add" event when the user adds a comment. We can write custom code and attach it to this event so that when the event
|
* an "add" event when the user adds a comment. We can write custom code and attach it to this event so that when the event
|
||||||
|
@ -55,12 +55,12 @@ class Security extends Component
|
|||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* @var string Hash algorithm for key derivation. Recommend sha256, sha384 or sha512.
|
* @var string Hash algorithm for key derivation. Recommend sha256, sha384 or sha512.
|
||||||
* @see hash_algos()
|
* @see [hash_algos()](http://php.net/manual/en/function.hash-algos.php)
|
||||||
*/
|
*/
|
||||||
public $kdfHash = 'sha256';
|
public $kdfHash = 'sha256';
|
||||||
/**
|
/**
|
||||||
* @var string Hash algorithm for message authentication. Recommend sha256, sha384 or sha512.
|
* @var string Hash algorithm for message authentication. Recommend sha256, sha384 or sha512.
|
||||||
* @see hash_algos()
|
* @see [hash_algos()](http://php.net/manual/en/function.hash-algos.php)
|
||||||
*/
|
*/
|
||||||
public $macHash = 'sha256';
|
public $macHash = 'sha256';
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ class AttributeBehavior extends Behavior
|
|||||||
public $attributes = [];
|
public $attributes = [];
|
||||||
/**
|
/**
|
||||||
* @var mixed the value that will be assigned to the current attributes. This can be an anonymous function,
|
* @var mixed the value that will be assigned to the current attributes. This can be an anonymous function,
|
||||||
* callable in array format (e.g. `[$this, 'methodName']`), an [[Expression]] object representing a DB expression
|
* callable in array format (e.g. `[$this, 'methodName']`), an [[\yii\db\Expression|Expression]] object representing a DB expression
|
||||||
* (e.g. `new Expression('NOW()')`), scalar, string or an arbitrary value. If the former, the return value of the
|
* (e.g. `new Expression('NOW()')`), scalar, string or an arbitrary value. If the former, the return value of the
|
||||||
* function will be assigned to the attributes.
|
* function will be assigned to the attributes.
|
||||||
* The signature of the function should be as follows,
|
* The signature of the function should be as follows,
|
||||||
|
@ -286,7 +286,7 @@ class MemCache extends Cache
|
|||||||
*
|
*
|
||||||
* @param string $key the key identifying the value to be cached
|
* @param string $key the key identifying the value to be cached
|
||||||
* @param mixed $value the value to be cached.
|
* @param mixed $value the value to be cached.
|
||||||
* @see \MemcachePool::set()
|
* @see [Memcache::set()](http://php.net/manual/en/memcache.set.php)
|
||||||
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
|
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
|
||||||
* @return bool true if the value is successfully stored into cache, false otherwise
|
* @return bool true if the value is successfully stored into cache, false otherwise
|
||||||
*/
|
*/
|
||||||
@ -327,7 +327,7 @@ class MemCache extends Cache
|
|||||||
*
|
*
|
||||||
* @param string $key the key identifying the value to be cached
|
* @param string $key the key identifying the value to be cached
|
||||||
* @param mixed $value the value to be cached
|
* @param mixed $value the value to be cached
|
||||||
* @see \MemcachePool::set()
|
* @see [Memcache::set()](http://php.net/manual/en/memcache.set.php)
|
||||||
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
|
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
|
||||||
* @return bool true if the value is successfully stored into cache, false otherwise
|
* @return bool true if the value is successfully stored into cache, false otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,7 @@ use yii\widgets\InputWidget;
|
|||||||
* ]);
|
* ]);
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
|
* You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]]
|
||||||
* method, for example like this:
|
* method, for example like this:
|
||||||
*
|
*
|
||||||
* ```php
|
* ```php
|
||||||
|
@ -84,7 +84,7 @@ class CaptchaValidator extends Validator
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function clientValidateAttribute($object, $attribute, $view)
|
public function clientValidateAttribute($model, $attribute, $view)
|
||||||
{
|
{
|
||||||
$captcha = $this->createCaptchaAction();
|
$captcha = $this->createCaptchaAction();
|
||||||
$code = $captcha->getVerifyCode(false);
|
$code = $captcha->getVerifyCode(false);
|
||||||
@ -94,7 +94,7 @@ class CaptchaValidator extends Validator
|
|||||||
'hashKey' => 'yiiCaptcha/' . $captcha->getUniqueId(),
|
'hashKey' => 'yiiCaptcha/' . $captcha->getUniqueId(),
|
||||||
'caseSensitive' => $this->caseSensitive,
|
'caseSensitive' => $this->caseSensitive,
|
||||||
'message' => Yii::$app->getI18n()->format($this->message, [
|
'message' => Yii::$app->getI18n()->format($this->message, [
|
||||||
'attribute' => $object->getAttributeLabel($attribute),
|
'attribute' => $model->getAttributeLabel($attribute),
|
||||||
], Yii::$app->language),
|
], Yii::$app->language),
|
||||||
];
|
];
|
||||||
if ($this->skipOnEmpty) {
|
if ($this->skipOnEmpty) {
|
||||||
|
@ -336,7 +336,7 @@ class Controller extends \yii\base\Controller
|
|||||||
* where the keys is alias name for option and value is option name.
|
* where the keys is alias name for option and value is option name.
|
||||||
*
|
*
|
||||||
* @since 2.0.8
|
* @since 2.0.8
|
||||||
* @see options($actionID)
|
* @see options()
|
||||||
*/
|
*/
|
||||||
public function optionAliases()
|
public function optionAliases()
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,10 @@ class Markdown extends \cebe\markdown\Parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* Render a paragraph block
|
||||||
|
*
|
||||||
|
* @param string $block
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function renderParagraph($block)
|
protected function renderParagraph($block)
|
||||||
{
|
{
|
||||||
|
@ -284,10 +284,10 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes query and returns a single row of result.
|
* Executes query and returns a single row of result.
|
||||||
* @param Connection $db the DB connection used to create the DB command.
|
* @param Connection|null $db the DB connection used to create the DB command.
|
||||||
* If null, the DB connection returned by [[modelClass]] will be used.
|
* If `null`, the DB connection returned by [[modelClass]] will be used.
|
||||||
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]],
|
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]],
|
||||||
* the query result may be either an array or an ActiveRecord object. Null will be returned
|
* the query result may be either an array or an ActiveRecord object. `null` will be returned
|
||||||
* if the query results in nothing.
|
* if the query results in nothing.
|
||||||
*/
|
*/
|
||||||
public function one($db = null)
|
public function one($db = null)
|
||||||
@ -303,8 +303,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a DB command that can be used to execute this query.
|
* Creates a DB command that can be used to execute this query.
|
||||||
* @param Connection $db the DB connection used to create the DB command.
|
* @param Connection|null $db the DB connection used to create the DB command.
|
||||||
* If null, the DB connection returned by [[modelClass]] will be used.
|
* If `null`, the DB connection returned by [[modelClass]] will be used.
|
||||||
* @return Command the created DB command instance.
|
* @return Command the created DB command instance.
|
||||||
*/
|
*/
|
||||||
public function createCommand($db = null)
|
public function createCommand($db = null)
|
||||||
|
@ -32,7 +32,7 @@ interface ActiveQueryInterface extends QueryInterface
|
|||||||
/**
|
/**
|
||||||
* Executes query and returns a single row of result.
|
* Executes query and returns a single row of result.
|
||||||
* @param Connection $db the DB connection used to create the DB command.
|
* @param Connection $db the DB connection used to create the DB command.
|
||||||
* If `null`, the DB connection returned by [[modelClass]] will be used.
|
* If `null`, the DB connection returned by [[ActiveQueryTrait::$modelClass|modelClass]] will be used.
|
||||||
* @return ActiveRecordInterface|array|null a single row of query result. Depending on the setting of [[asArray]],
|
* @return ActiveRecordInterface|array|null a single row of query result. Depending on the setting of [[asArray]],
|
||||||
* the query result may be either an array or an ActiveRecord object. `null` will be returned
|
* the query result may be either an array or an ActiveRecord object. `null` will be returned
|
||||||
* if the query results in nothing.
|
* if the query results in nothing.
|
||||||
|
@ -276,7 +276,7 @@ interface ActiveRecordInterface
|
|||||||
* $customer->save();
|
* $customer->save();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
|
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
|
||||||
* before saving the record. Defaults to `true`. If the validation fails, the record
|
* before saving the record. Defaults to `true`. If the validation fails, the record
|
||||||
* will not be saved to the database and this method will return `false`.
|
* will not be saved to the database and this method will return `false`.
|
||||||
* @param array $attributeNames list of attribute names that need to be saved. Defaults to `null`,
|
* @param array $attributeNames list of attribute names that need to be saved. Defaults to `null`,
|
||||||
@ -297,7 +297,7 @@ interface ActiveRecordInterface
|
|||||||
* $customer->insert();
|
* $customer->insert();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
|
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
|
||||||
* before saving the record. Defaults to `true`. If the validation fails, the record
|
* before saving the record. Defaults to `true`. If the validation fails, the record
|
||||||
* will not be saved to the database and this method will return `false`.
|
* will not be saved to the database and this method will return `false`.
|
||||||
* @param array $attributes list of attributes that need to be saved. Defaults to `null`,
|
* @param array $attributes list of attributes that need to be saved. Defaults to `null`,
|
||||||
@ -318,7 +318,7 @@ interface ActiveRecordInterface
|
|||||||
* $customer->update();
|
* $customer->update();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
|
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
|
||||||
* before saving the record. Defaults to `true`. If the validation fails, the record
|
* before saving the record. Defaults to `true`. If the validation fails, the record
|
||||||
* will not be saved to the database and this method will return `false`.
|
* will not be saved to the database and this method will return `false`.
|
||||||
* @param array $attributeNames list of attributes that need to be saved. Defaults to `null`,
|
* @param array $attributeNames list of attributes that need to be saved. Defaults to `null`,
|
||||||
|
@ -947,7 +947,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
|||||||
* already the new, updated values.
|
* already the new, updated values.
|
||||||
*
|
*
|
||||||
* Note that no automatic type conversion performed by default. You may use
|
* Note that no automatic type conversion performed by default. You may use
|
||||||
* [[yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting.
|
* [[\yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting.
|
||||||
* See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.
|
* See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.
|
||||||
*/
|
*/
|
||||||
public function afterSave($insert, $changedAttributes)
|
public function afterSave($insert, $changedAttributes)
|
||||||
|
@ -283,7 +283,7 @@ class Connection extends Component
|
|||||||
'cubrid' => 'yii\db\cubrid\Schema', // CUBRID
|
'cubrid' => 'yii\db\cubrid\Schema', // CUBRID
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
* @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[yii\db\mssql\PDO]] when MSSQL is used.
|
* @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[\yii\db\mssql\PDO]] when MSSQL is used.
|
||||||
* @see pdo
|
* @see pdo
|
||||||
*/
|
*/
|
||||||
public $pdoClass;
|
public $pdoClass;
|
||||||
|
@ -65,9 +65,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
/**
|
/**
|
||||||
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
|
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
|
||||||
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
||||||
* @param array $orderBy the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
|
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
|
||||||
* @param int $limit the limit number. See [[Query::limit]] for more details.
|
* @param int $limit the limit number. See [[\yii\db\Query::limit]] for more details.
|
||||||
* @param int $offset the offset number. See [[Query::offset]] for more details.
|
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
|
||||||
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
||||||
*/
|
*/
|
||||||
protected function newBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)
|
protected function newBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)
|
||||||
@ -92,9 +92,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
|||||||
/**
|
/**
|
||||||
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
|
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
|
||||||
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
|
||||||
* @param array $orderBy the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
|
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
|
||||||
* @param int $limit the limit number. See [[Query::limit]] for more details.
|
* @param int $limit the limit number. See [[\yii\db\Query::limit]] for more details.
|
||||||
* @param int $offset the offset number. See [[Query::offset]] for more details.
|
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
|
||||||
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
|
||||||
*/
|
*/
|
||||||
protected function oldBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)
|
protected function oldBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)
|
||||||
|
@ -207,7 +207,7 @@ class Cors extends ActionFilter
|
|||||||
/**
|
/**
|
||||||
* Adds the CORS headers to the response
|
* Adds the CORS headers to the response
|
||||||
* @param Response $response
|
* @param Response $response
|
||||||
* @param array CORS headers which have been computed
|
* @param array $headers CORS headers which have been computed
|
||||||
*/
|
*/
|
||||||
public function addCorsHeaders($response, $headers)
|
public function addCorsHeaders($response, $headers)
|
||||||
{
|
{
|
||||||
|
@ -480,8 +480,8 @@ class BaseInflector
|
|||||||
* of the helper.
|
* of the helper.
|
||||||
*
|
*
|
||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
* @param string|\Transliterator $transliterator either a [[Transliterator]] or a string
|
* @param string|\Transliterator $transliterator either a [[\Transliterator]] or a string
|
||||||
* from which a [[Transliterator]] can be built.
|
* from which a [[\Transliterator]] can be built.
|
||||||
* @return string
|
* @return string
|
||||||
* @since 2.0.7 this method is public.
|
* @since 2.0.7 this method is public.
|
||||||
*/
|
*/
|
||||||
|
@ -1131,7 +1131,7 @@ class Formatter extends Component
|
|||||||
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
|
||||||
* @return string the formatted result.
|
* @return string the formatted result.
|
||||||
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
|
||||||
* @see sizeFormat
|
* @see sizeFormatBase
|
||||||
* @see asSize
|
* @see asSize
|
||||||
*/
|
*/
|
||||||
public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
|
public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
|
||||||
@ -1187,7 +1187,7 @@ class Formatter extends Component
|
|||||||
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
|
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
|
||||||
* @return string the formatted result.
|
* @return string the formatted result.
|
||||||
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
|
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
|
||||||
* @see sizeFormat
|
* @see sizeFormatBase
|
||||||
* @see asShortSize
|
* @see asShortSize
|
||||||
*/
|
*/
|
||||||
public function asSize($value, $decimals = null, $options = [], $textOptions = [])
|
public function asSize($value, $decimals = null, $options = [], $textOptions = [])
|
||||||
|
@ -42,7 +42,7 @@ class EachValidator extends Validator
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array|Validator definition of the validation rule, which should be used on array values.
|
* @var array|Validator definition of the validation rule, which should be used on array values.
|
||||||
* It should be specified in the same format as at [[yii\base\Model::rules()]], except it should not
|
* It should be specified in the same format as at [[\yii\base\Model::rules()]], except it should not
|
||||||
* contain attribute list as the first element.
|
* contain attribute list as the first element.
|
||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
@ -51,7 +51,7 @@ class EachValidator extends Validator
|
|||||||
* ['match', 'pattern' => '/[a-z]/is']
|
* ['match', 'pattern' => '/[a-z]/is']
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Please refer to [[yii\base\Model::rules()]] for more details.
|
* Please refer to [[\yii\base\Model::rules()]] for more details.
|
||||||
*/
|
*/
|
||||||
public $rule;
|
public $rule;
|
||||||
/**
|
/**
|
||||||
|
@ -222,56 +222,56 @@ class FileValidator extends Validator
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected function validateValue($file)
|
protected function validateValue($value)
|
||||||
{
|
{
|
||||||
if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) {
|
if (!$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE) {
|
||||||
return [$this->uploadRequired, []];
|
return [$this->uploadRequired, []];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($file->error) {
|
switch ($value->error) {
|
||||||
case UPLOAD_ERR_OK:
|
case UPLOAD_ERR_OK:
|
||||||
if ($this->maxSize !== null && $file->size > $this->getSizeLimit()) {
|
if ($this->maxSize !== null && $value->size > $this->getSizeLimit()) {
|
||||||
return [
|
return [
|
||||||
$this->tooBig,
|
$this->tooBig,
|
||||||
[
|
[
|
||||||
'file' => $file->name,
|
'file' => $value->name,
|
||||||
'limit' => $this->getSizeLimit(),
|
'limit' => $this->getSizeLimit(),
|
||||||
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
|
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
} elseif ($this->minSize !== null && $file->size < $this->minSize) {
|
} elseif ($this->minSize !== null && $value->size < $this->minSize) {
|
||||||
return [
|
return [
|
||||||
$this->tooSmall,
|
$this->tooSmall,
|
||||||
[
|
[
|
||||||
'file' => $file->name,
|
'file' => $value->name,
|
||||||
'limit' => $this->minSize,
|
'limit' => $this->minSize,
|
||||||
'formattedLimit' => Yii::$app->formatter->asShortSize($this->minSize),
|
'formattedLimit' => Yii::$app->formatter->asShortSize($this->minSize),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
} elseif (!empty($this->extensions) && !$this->validateExtension($file)) {
|
} elseif (!empty($this->extensions) && !$this->validateExtension($value)) {
|
||||||
return [$this->wrongExtension, ['file' => $file->name, 'extensions' => implode(', ', $this->extensions)]];
|
return [$this->wrongExtension, ['file' => $value->name, 'extensions' => implode(', ', $this->extensions)]];
|
||||||
} elseif (!empty($this->mimeTypes) && !$this->validateMimeType($file)) {
|
} elseif (!empty($this->mimeTypes) && !$this->validateMimeType($value)) {
|
||||||
return [$this->wrongMimeType, ['file' => $file->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]];
|
return [$this->wrongMimeType, ['file' => $value->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case UPLOAD_ERR_INI_SIZE:
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
case UPLOAD_ERR_FORM_SIZE:
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
return [$this->tooBig, [
|
return [$this->tooBig, [
|
||||||
'file' => $file->name,
|
'file' => $value->name,
|
||||||
'limit' => $this->getSizeLimit(),
|
'limit' => $this->getSizeLimit(),
|
||||||
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
|
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
|
||||||
]];
|
]];
|
||||||
case UPLOAD_ERR_PARTIAL:
|
case UPLOAD_ERR_PARTIAL:
|
||||||
Yii::warning('File was only partially uploaded: ' . $file->name, __METHOD__);
|
Yii::warning('File was only partially uploaded: ' . $value->name, __METHOD__);
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_NO_TMP_DIR:
|
case UPLOAD_ERR_NO_TMP_DIR:
|
||||||
Yii::warning('Missing the temporary folder to store the uploaded file: ' . $file->name, __METHOD__);
|
Yii::warning('Missing the temporary folder to store the uploaded file: ' . $value->name, __METHOD__);
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_CANT_WRITE:
|
case UPLOAD_ERR_CANT_WRITE:
|
||||||
Yii::warning('Failed to write the uploaded file to disk: ' . $file->name, __METHOD__);
|
Yii::warning('Failed to write the uploaded file to disk: ' . $value->name, __METHOD__);
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_EXTENSION:
|
case UPLOAD_ERR_EXTENSION:
|
||||||
Yii::warning('File upload was stopped by some PHP extension: ' . $file->name, __METHOD__);
|
Yii::warning('File upload was stopped by some PHP extension: ' . $value->name, __METHOD__);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -312,6 +312,7 @@ class FileValidator extends Validator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
* @param bool $trim
|
||||||
*/
|
*/
|
||||||
public function isEmpty($value, $trim = false)
|
public function isEmpty($value, $trim = false)
|
||||||
{
|
{
|
||||||
|
@ -115,11 +115,11 @@ class ImageValidator extends FileValidator
|
|||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected function validateValue($file)
|
protected function validateValue($value)
|
||||||
{
|
{
|
||||||
$result = parent::validateValue($file);
|
$result = parent::validateValue($value);
|
||||||
|
|
||||||
return empty($result) ? $this->validateImage($file) : $result;
|
return empty($result) ? $this->validateImage($value) : $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,9 +291,9 @@ class AssetManager extends Component
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the actual URL for the specified asset.
|
* Returns the actual URL for the specified asset.
|
||||||
* The actual URL is obtained by prepending either [[baseUrl]] or [[AssetManager::baseUrl]] to the given asset path.
|
* The actual URL is obtained by prepending either [[AssetBundle::$baseUrl]] or [[AssetManager::$baseUrl]] to the given asset path.
|
||||||
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
|
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
|
||||||
* @param string $asset the asset path. This should be one of the assets listed in [[js]] or [[css]].
|
* @param string $asset the asset path. This should be one of the assets listed in [[AssetBundle::$js]] or [[AssetBundle::$css]].
|
||||||
* @return string the actual URL for the specified asset.
|
* @return string the actual URL for the specified asset.
|
||||||
*/
|
*/
|
||||||
public function getAssetUrl($bundle, $asset)
|
public function getAssetUrl($bundle, $asset)
|
||||||
@ -327,7 +327,7 @@ class AssetManager extends Component
|
|||||||
/**
|
/**
|
||||||
* Returns the actual file path for the specified asset.
|
* Returns the actual file path for the specified asset.
|
||||||
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
|
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
|
||||||
* @param string $asset the asset path. This should be one of the assets listed in [[js]] or [[css]].
|
* @param string $asset the asset path. This should be one of the assets listed in [[AssetBundle::$js]] or [[AssetBundle::$css]].
|
||||||
* @return string|false the actual file path, or `false` if the asset is specified as an absolute URL
|
* @return string|false the actual file path, or `false` if the asset is specified as an absolute URL
|
||||||
*/
|
*/
|
||||||
public function getAssetPath($bundle, $asset)
|
public function getAssetPath($bundle, $asset)
|
||||||
|
@ -406,7 +406,6 @@ class User extends Component
|
|||||||
* @return Response the redirection response if [[loginUrl]] is set
|
* @return Response the redirection response if [[loginUrl]] is set
|
||||||
* @throws ForbiddenHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set or a redirect is
|
* @throws ForbiddenHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set or a redirect is
|
||||||
* not applicable.
|
* not applicable.
|
||||||
* @see checkAcceptHeader
|
|
||||||
*/
|
*/
|
||||||
public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
|
public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ use yii\web\View;
|
|||||||
* ]);
|
* ]);
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
|
* You can also use this widget in an [[ActiveForm]] using the [[ActiveField::widget()|widget()]]
|
||||||
* method, for example like this:
|
* method, for example like this:
|
||||||
*
|
*
|
||||||
* ```php
|
* ```php
|
||||||
|
Reference in New Issue
Block a user