PHP Класс Tools\Model\Behavior\ResetBehavior
This way any slugging, geocoding or other beforeRules, beforeSave, ... callbacks
can be retriggered for them.
By default it will not update the modified timestamp and will re-save id and displayName.
If you need more fields, you need to specify them manually.
You can also disable validate callback or provide a conditions scope to match only a subset
of records.
For performance and memory reasons the records will only be processed in loops (not all at once).
If you have time-sensitive data, you can modify the limit of records per loop as well as the
timeout in between each loop.
Remember to raise set_time_limit() if you do not run this via CLI.
It is recommended to attach this behavior dynamically where needed:
$table->addBehavior('Tools.Reset', array(...));
$table->resetRecords();
If you want to provide a callback function/method, you can either use object methods or
static functions/methods:
'callback' => array($this, 'methodName')
and
public function methodName(Entity $entity, &$fields) }
For tables with lots of records you might want to use a shell and the CLI to invoke the reset/update process.
Показать файл
Открыть проект
Защищенные свойства (Protected)
Открытые методы
Метод |
Описание |
|
__construct ( Table $table, array $config = [] ) |
Adding validation rules
also adds and merges config settings (direct + configure) |
|
resetRecords ( array $params = [] ) : integer |
Regenerate all records (including possible beforeRules/beforeSave callbacks). |
|
Описание методов
__construct()
публичный Метод
Adding validation rules
also adds and merges config settings (direct + configure)
resetRecords()
публичный Метод
Regenerate all records (including possible beforeRules/beforeSave callbacks).
Описание свойств
$_defaultConfig защищенное свойство
protected array $_defaultConfig |
Результат |
array |
|