Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
8fb82c2f
Commit
8fb82c2f
authored
Oct 08, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #427, now the AuditLog component should work
parent
1f1fef74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
AuditLog.php
lib/Doctrine/AuditLog.php
+9
-2
Listener.php
lib/Doctrine/AuditLog/Listener.php
+17
-7
No files found.
lib/Doctrine/AuditLog.php
View file @
8fb82c2f
...
...
@@ -74,13 +74,20 @@ class Doctrine_AuditLog extends Doctrine_Plugin
$name
=
$table
->
getComponentName
();
$className
=
$name
.
'Version'
;
// check that class doesn't exist (otherwise we cannot create it)
if
(
class_exists
(
$className
))
{
return
false
;
}
$columns
=
$table
->
getColumns
();
// remove all sequential and autoincrement definitions
foreach
(
$columns
as
$column
=>
$definition
)
{
unset
(
$columns
[
$column
][
'autoincrement'
]);
unset
(
$columns
[
$column
][
'sequence'
]);
}
// the version column should be part of the primary key definition
$columns
[
$this
->
_options
[
'versionColumn'
]][
'primary'
]
=
true
;
...
...
lib/Doctrine/AuditLog/Listener.php
View file @
8fb82c2f
...
...
@@ -44,7 +44,7 @@ class Doctrine_AuditLog_Listener extends Doctrine_Record_Listener
$event
->
getInvoker
()
->
set
(
$versionColumn
,
1
);
}
public
function
p
reDelete
(
Doctrine_Event
$event
)
public
function
p
ostInsert
(
Doctrine_Event
$event
)
{
$class
=
$this
->
_auditLog
->
getOption
(
'className'
);
...
...
@@ -53,25 +53,35 @@ class Doctrine_AuditLog_Listener extends Doctrine_Record_Listener
$version
=
new
$class
();
$version
->
merge
(
$record
->
toArray
());
$version
->
save
();
}
public
function
preDelete
(
Doctrine_Event
$event
)
{
$class
=
$this
->
_auditLog
->
getOption
(
'className'
);
$record
=
$event
->
getInvoker
();
$versionColumn
=
$this
->
_auditLog
->
getOption
(
'versionColumn'
);
$version
=
$record
->
get
(
$versionColumn
);
$record
->
set
(
$versionColumn
,
++
$version
);
$version
=
new
$class
();
$version
->
merge
(
$record
->
toArray
());
$version
->
save
();
}
public
function
preUpdate
(
Doctrine_Event
$event
)
{
$class
=
$this
->
_auditLog
->
getOption
(
'className'
);
$record
=
$event
->
getInvoker
();
$version
=
new
$class
();
$version
->
merge
(
$record
->
toArray
());
$version
->
save
();
$class
=
$this
->
_auditLog
->
getOption
(
'className'
);
$record
=
$event
->
getInvoker
();
$versionColumn
=
$this
->
_auditLog
->
getOption
(
'versionColumn'
);
$version
=
$record
->
get
(
$versionColumn
);
$record
->
set
(
$versionColumn
,
++
$version
);
$version
=
new
$class
();
$version
->
merge
(
$record
->
toArray
());
$version
->
save
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment