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
6823c765
Commit
6823c765
authored
Jul 17, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
1633b07f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
AuditLog.php
lib/Doctrine/AuditLog.php
+14
-9
Listener.php
lib/Doctrine/AuditLog/Listener.php
+13
-4
No files found.
lib/Doctrine/AuditLog.php
View file @
6823c765
...
...
@@ -35,7 +35,7 @@ class Doctrine_AuditLog
'className'
=>
'%CLASS%Version'
,
'versionColumn'
=>
'version'
,
'generateFiles'
=>
false
,
'table'
=>
null
,
'table'
=>
false
,
);
protected
$_auditTable
;
...
...
@@ -43,6 +43,10 @@ class Doctrine_AuditLog
public
function
__construct
(
$options
)
{
$this
->
_options
=
array_merge
(
$this
->
_options
,
$options
);
$this
->
_options
[
'className'
]
=
str_replace
(
'%CLASS%'
,
$this
->
_options
[
'table'
]
->
getComponentName
(),
$this
->
_options
[
'className'
]);
}
/**
* __get
...
...
@@ -110,12 +114,12 @@ class Doctrine_AuditLog
public
function
getVersion
(
Doctrine_Record
$record
,
$version
)
{
$className
=
str_replace
(
'%CLASS%'
,
$this
->
_table
->
getComponentName
(),
$this
->
_options
[
'className'
])
;
$className
=
$this
->
_options
[
'className'
]
;
$q
=
new
Doctrine_Query
();
$values
=
array
();
foreach
((
array
)
$this
->
_
table
->
getIdentifier
()
as
$id
)
{
foreach
((
array
)
$this
->
_
options
[
'table'
]
->
getIdentifier
()
as
$id
)
{
$conditions
[]
=
$className
.
'.'
.
$id
.
' = ?'
;
$values
[]
=
$record
->
get
(
$id
);
}
...
...
@@ -123,9 +127,10 @@ class Doctrine_AuditLog
$values
[]
=
$version
;
return
$q
->
from
(
$className
)
->
where
(
$where
)
->
execute
(
$values
,
Doctrine_HYDRATE
::
HYDRATE_ARRAY
);
$q
->
from
(
$className
)
->
where
(
$where
);
return
$q
->
execute
(
$values
,
Doctrine_HYDRATE
::
HYDRATE_ARRAY
);
}
public
function
buildDefinition
(
Doctrine_Table
$table
)
{
...
...
lib/Doctrine/AuditLog/Listener.php
View file @
6823c765
...
...
@@ -38,22 +38,31 @@ class Doctrine_AuditLog_Listener extends Doctrine_Record_Listener
public
function
__construct
(
Doctrine_AuditLog
$auditLog
)
{
$this
->
_auditLog
=
$auditLog
;
}
public
function
onPreInsert
(
Doctrine_Record
$record
)
public
function
preInsert
(
Doctrine_Event
$event
)
{
$versionColumn
=
$this
->
_auditLog
->
getOption
(
'versionColumn'
);
$
record
->
set
(
$versionColumn
,
1
);
$
event
->
getInvoker
()
->
set
(
$versionColumn
,
1
);
}
public
function
onPreDelete
(
Doctrine_Record
$record
)
public
function
preDelete
(
Doctrine_Event
$event
)
{
$class
=
$this
->
_auditLog
->
getOption
(
'className'
);
$record
=
$event
->
getInvoker
();
$version
=
new
$class
();
$version
->
merge
(
$record
->
toArray
());
$versionColumn
=
$this
->
_auditLog
->
getOption
(
'versionColumn'
);
$version
=
$record
->
get
(
$versionColumn
);
$record
->
set
(
$versionColumn
,
++
$version
);
}
public
function
onPreUpdate
(
Doctrine_Record
$record
)
public
function
preUpdate
(
Doctrine_Event
$event
)
{
$versionColumn
=
$this
->
_auditLog
->
getOption
(
'versionColumn'
);
$record
=
$event
->
getInvoker
();
$version
=
$record
->
get
(
$versionColumn
);
$record
->
set
(
$versionColumn
,
++
$version
);
...
...
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