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.
Author: Mark Scherer
Inheritance: extends Cake\ORM\Behavior
Show file Open project: dereuromark/cakephp-tools

Protected Properties

Property Type Description
$_defaultConfig array

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)
public __construct ( Table $table, array $config = [] )
$table Cake\ORM\Table
$config array

resetRecords() public method

Regenerate all records (including possible beforeRules/beforeSave callbacks).
public resetRecords ( array $params = [] ) : integer
$params array
return integer Modified records

Property Details

$_defaultConfig protected property

protected array $_defaultConfig
return array