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
832a8e55
Commit
832a8e55
authored
Nov 01, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored code to less lines.
parent
84d5845b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
31 deletions
+11
-31
Timestampable.php
lib/Doctrine/Template/Timestampable.php
+11
-31
No files found.
lib/Doctrine/Template/Timestampable.php
View file @
832a8e55
...
...
@@ -39,7 +39,14 @@ class Doctrine_Template_Timestampable extends Doctrine_Template
*
* @var string
*/
protected
$_options
=
array
();
protected
$_options
=
array
(
'created'
=>
array
(
'name'
=>
'created_at'
,
'type'
=>
'timestamp'
,
'format'
=>
'Y-m-d H:i:s'
,
'options'
=>
array
()),
'updated'
=>
array
(
'name'
=>
'updated_at'
,
'type'
=>
'timestamp'
,
'format'
=>
'Y-m-d H:i:s'
,
'options'
=>
array
()));
/**
* __construct
...
...
@@ -49,7 +56,7 @@ class Doctrine_Template_Timestampable extends Doctrine_Template
*/
public
function
__construct
(
array
$options
)
{
$this
->
_options
=
$options
;
$this
->
_options
=
array_merge
(
$options
,
$this
->
_options
)
;
}
/**
...
...
@@ -59,35 +66,8 @@ class Doctrine_Template_Timestampable extends Doctrine_Template
*/
public
function
setTableDefinition
()
{
$createdOptions
=
array
();
$updatedOptions
=
array
();
if
(
isset
(
$this
->
_options
[
'created'
]))
{
$createdOptions
=
$this
->
_options
[
'created'
];
unset
(
$createdOptions
[
'name'
]);
unset
(
$createdOptions
[
'type'
]);
}
if
(
isset
(
$this
->
_options
[
'updated'
]))
{
$updatedOptions
=
$this
->
_options
[
'updated'
];
unset
(
$updatedOptions
[
'name'
]);
unset
(
$updatedOptions
[
'type'
]);
}
$createdName
=
isset
(
$this
->
_options
[
'created'
][
'name'
])
?
$this
->
_options
[
'created'
][
'name'
]
:
'created_at'
;
$createdType
=
isset
(
$this
->
_options
[
'created'
][
'type'
])
?
$this
->
_options
[
'created'
][
'type'
]
:
'timestamp'
;
$updatedName
=
isset
(
$this
->
_options
[
'updated'
][
'name'
])
?
$this
->
_options
[
'updated'
][
'name'
]
:
'updated_at'
;
$updatedType
=
isset
(
$this
->
_options
[
'updated'
][
'type'
])
?
$this
->
_options
[
'updated'
][
'type'
]
:
'timestamp'
;
$this
->
hasColumn
(
$createdName
,
$createdType
,
null
,
$createdOptions
);
$this
->
hasColumn
(
$updatedName
,
$updatedType
,
null
,
$updatedOptions
);
$this
->
_options
[
'created'
][
'name'
]
=
$createdName
;
$this
->
_options
[
'created'
][
'type'
]
=
$createdType
;
$this
->
_options
[
'updated'
][
'name'
]
=
$updatedName
;
$this
->
_options
[
'updated'
][
'type'
]
=
$updatedType
;
$this
->
hasColumn
(
$this
->
_options
[
'created'
][
'name'
],
$this
->
_options
[
'created'
][
'type'
],
null
,
$this
->
_options
[
'created'
][
'name'
]);
$this
->
hasColumn
(
$this
->
_options
[
'updated'
][
'name'
],
$this
->
_options
[
'updated'
][
'type'
],
null
,
$this
->
_options
[
'updated'
][
'name'
]);
$this
->
addListener
(
new
Doctrine_Timestampable_Listener
(
$this
->
_options
));
}
...
...
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