mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
Fixes #4048: Added init
event to ActiveQuery
classes
This commit is contained in:
@ -77,6 +77,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -89,6 +94,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DB command that can be used to execute this query.
|
||||
* @param Connection $db the DB connection used to create the DB command.
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace yii\elasticsearch;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidCallException;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\db\BaseActiveRecord;
|
||||
@ -71,7 +72,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ Yii Framework 2 elasticsearch extension Change Log
|
||||
- Bug #4187: Elasticsearch dynamic scripting is disabled in 1.2.0, so do not use it in query builder (cebe)
|
||||
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
||||
- Enh #3527: Added `highlight` property to Query and ActiveRecord. (Borales)
|
||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
||||
- Enh: Make error messages more readable in HTML output (cebe)
|
||||
- Chg: asArray in ActiveQuery is now equal to using the normal Query. This means, that the output structure has changed and `with` is supported anymore. (cebe)
|
||||
|
@ -64,6 +64,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -76,6 +81,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace yii\mongodb;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\db\BaseActiveRecord;
|
||||
use yii\db\StaleObjectException;
|
||||
@ -96,7 +97,7 @@ abstract class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,7 @@ Yii Framework 2 mongodb extension Change Log
|
||||
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
||||
- Enh #3778: Gii generator for Active Record model added (klimov-paul)
|
||||
- Enh #3947: Migration support added (klimov-paul)
|
||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
||||
- Enh #4335: `yii\mongodb\log\MongoDbTarget` log target added (klimov-paul)
|
||||
|
||||
|
@ -40,6 +40,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -52,6 +57,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query and returns all results as an array.
|
||||
* @param \yii\mongodb\Connection $db the Mongo connection used to execute the query.
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace yii\mongodb\file;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidParamException;
|
||||
use yii\db\StaleObjectException;
|
||||
use yii\web\UploadedFile;
|
||||
@ -49,7 +50,7 @@ abstract class ActiveRecord extends \yii\mongodb\ActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,6 +77,10 @@ class ActiveQuery extends Component implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -89,6 +93,18 @@ class ActiveQuery extends Component implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the query and returns all results as an array.
|
||||
* @param Connection $db the database connection used to execute the query.
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
namespace yii\redis;
|
||||
|
||||
use Yii;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\db\BaseActiveRecord;
|
||||
use yii\helpers\Inflector;
|
||||
@ -53,7 +54,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ Yii Framework 2 redis extension Change Log
|
||||
--------------------------
|
||||
|
||||
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
||||
|
||||
|
||||
|
@ -85,6 +85,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
/**
|
||||
* @var string the SQL statement to be executed for retrieving AR records.
|
||||
* This is set by [[ActiveRecord::findBySql()]].
|
||||
@ -103,6 +108,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [[snippetCallback]] to [[fetchSnippetSourceFromModels()]], which allows to
|
||||
* fetch the snippet source strings from the Active Record models, using method
|
||||
|
@ -140,7 +140,7 @@ abstract class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ Yii Framework 2 sphinx extension Change Log
|
||||
- Bug #3668: Escaping of the special characters at 'MATCH' statement added (klimov-paul)
|
||||
- Bug #4018: AR relation eager loading does not work with db models (klimov-paul)
|
||||
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
|
||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||
- Enh #4086: changedAttributes of afterSave Event now contain old values (dizews)
|
||||
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
|
||||
- Chg #2287: Split `yii\sphinx\ColumnSchema::typecast()` into two methods `phpTypecast()` and `dbTypecast()` to allow specifying PDO type explicitly (cebe)
|
||||
|
@ -130,6 +130,7 @@ Yii Framework 2 Change Log
|
||||
- Added note about the fact that intl is required for non-latin languages to requirements checker.
|
||||
- Enh #3992: In mail layouts you can now access the message object via `$message` variable (qiangxue)
|
||||
- Enh #4028: Added ability to `yii\widgets\Menu` to encode each item's label separately (creocoder, umneeq)
|
||||
- Enh #4048: Added `init` event to `ActiveQuery` classes (qiangxue)
|
||||
- Enh #4072: `\yii\rbac\PhpManager` adjustments (samdark)
|
||||
- Data is now stored in three separate files for items, assignments and rules. File format is simpler.
|
||||
- Removed `authFile`. Added `itemFile`, `assignmentFile` and `ruleFile`.
|
||||
|
@ -72,6 +72,11 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
use ActiveQueryTrait;
|
||||
use ActiveRelationTrait;
|
||||
|
||||
/**
|
||||
* @event Event an event that is triggered when the query is initialized via [[init()]].
|
||||
*/
|
||||
const EVENT_INIT = 'init';
|
||||
|
||||
/**
|
||||
* @var string the SQL statement to be executed for retrieving AR records.
|
||||
* This is set by [[ActiveRecord::findBySql()]].
|
||||
@ -102,6 +107,18 @@ class ActiveQuery extends Query implements ActiveQueryInterface
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object.
|
||||
* This method is called at the end of the constructor. The default implementation will trigger
|
||||
* an [[EVENT_INIT]] event. If you override this method, make sure you call the parent implementation at the end
|
||||
* to ensure triggering of the event.
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->trigger(self::EVENT_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query and returns all results as an array.
|
||||
* @param Connection $db the DB connection used to create the DB command.
|
||||
|
@ -258,7 +258,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ActiveQuery(get_called_class());
|
||||
return Yii::createObject(ActiveQuery::className(), [get_called_class()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user