/**
* Method to reset class properties to the defaults set in the class
* definition. It will ignore the primary key as well as any private class
* properties (except $_errors).
*
* @return void
*
* @since 1.7.0
*/
public function reset()
{
$event = AbstractEvent::create('onTableBeforeReset', ['subject' => $this]);
$this->getDispatcher()->dispatch('onTableBeforeReset', $event);
// Get the default values for the class from the table.
foreach ($this->getFields() as $k => $v) {
// If the property is not the primary key or private, reset it.
if (!\in_array($k, $this->_tbl_keys) && strpos($k, '_') !== 0) {
$this->{$k} = $v->Default;
}
}
// Reset table errors
$this->_errors = array();
$event = AbstractEvent::create('onTableAfterReset', ['subject' => $this]);
$this->getDispatcher()->dispatch('onTableAfterReset', $event);
}