Inherits Doctrine_Record_Listener.
Inherited by Doctrine_AuditLog_Listener_Microtime.
Definition at line 33 of file Listener.php.
Instantiate AuditLog listener and set the Doctrine_AuditLog instance to the class
- Parameters
-
- Returns
- void
Definition at line 48 of file Listener.php.
{
$this->_auditLog = $auditLog;
}
Get the initial version number for the audit log
- Parameters
-
- Returns
- integer $initialVersion
Definition at line 147 of file Listener.php.
Get the next version number for the audit log
- Parameters
-
- Returns
- integer $nextVersion
Definition at line 158 of file Listener.php.
{
if ($this->_auditLog->getOption('auditLog')) {
return ($this->_auditLog->getMaxVersion($record) + 1);
}
}
| Doctrine_Record_Listener::getOption |
( |
|
$name | ) |
|
|
inherited |
getOption returns the value of given option
- Parameters
-
| string | $name | the name of the option |
- Returns
- mixed the value of given option
Definition at line 74 of file Listener.php.
{
if (isset($this->_options[$name])) {
return $this->_options[$name];
}
return null;
}
| Doctrine_Record_Listener::getOptions |
( |
| ) |
|
|
inherited |
getOptions returns all options of this template and the associated values
- Returns
- array all options and their values
Definition at line 62 of file Listener.php.
{
return $this->_options;
}
Post insert event hook which creates the new version record This will only insert a version record if the auditLog is enabled
- Parameters
-
- Returns
- void
Definition at line 75 of file Listener.php.
{
if ($this->_auditLog->getOption('auditLog')) {
$class = $this->_auditLog->getOption('className');
$version = new $class();
$version->merge($record->toArray(), false);
$version->save();
}
}
Pre delete event hook deletes all related versions This will only delete version records if the auditLog is enabled
- Parameters
-
- Returns
- void
Definition at line 94 of file Listener.php.
{
if ($this->_auditLog->getOption('auditLog')) {
$className = $this->_auditLog->getOption('className');
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
if ($this->_auditLog->getOption('deleteVersions')) {
->createQuery('obj')
->delete();
foreach ((array) $this->_auditLog->getOption('table')->getIdentifier() as $id) {
$conditions[] = 'obj.' . $id . ' = ?';
}
$rows = $q->where(implode(' AND ', $conditions))
->execute($values);
}
}
}
Pre insert event hook for incrementing version number
- Parameters
-
- Returns
- void
Definition at line 59 of file Listener.php.
{
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
}
Pre update event hook for inserting new version record This will only insert a version record if the auditLog is enabled
- Parameters
-
- Returns
- void
Definition at line 124 of file Listener.php.
{
if ($this->_auditLog->getOption('auditLog')) {
$class = $this->_auditLog->getOption('className');
$version = $this->_auditLog->getOption('version');
$name = $version['alias'] === null ? $version['name'] : $version['alias'];
$version = new $class();
$version->merge($record->toArray(), false);
$version->save();
}
}
| Doctrine_Record_Listener::setOption |
( |
|
$name, |
|
|
|
$value = null |
|
) |
| |
|
inherited |
setOption sets an option in order to allow flexible listener
- Parameters
-
| mixed | $name | the name of the option to set |
| mixed | $value | the value of the option |
Definition at line 47 of file Listener.php.
{
if (is_array($name)) {
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $name);
} else {
$this->_options[$name] = $value;
}
}
The documentation for this class was generated from the following file: