PHP Class 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.
显示文件
Open project: dereuromark/cakephp-tools
Protected Properties
Public Methods
Method |
Description |
|
__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). |
|
Method Details
__construct()
public method
Adding validation rules
also adds and merges config settings (direct + configure)
resetRecords()
public method
Regenerate all records (including possible beforeRules/beforeSave callbacks).
Property Details
$_defaultConfig protected_oe property
protected array $_defaultConfig |
return |
array |
|