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
faa5763a
Commit
faa5763a
authored
Sep 20, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
da437ddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
109 deletions
+13
-109
Filter.php
lib/Doctrine/Record/Filter.php
+13
-109
No files found.
lib/Doctrine/Record/Filter.php
View file @
faa5763a
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
/**
/**
* Doctrine_Record_Filter
* Doctrine_Record_Filter
* Filters
and prepares the record data
* Filters
the record getters and setters
*
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
* @since 1.0
* @since 1.0
* @version $Revision: 1298 $
* @version $Revision: 1298 $
*/
*/
class
Doctrine_Record_Filter
extends
Doctrine_Object
class
Doctrine_Record_Filter
{
{
/**
/**
* @var Doctrine_Record $_record the record object this filter belongs to
* @var Doctrine_Record $_record the record object this filter belongs to
...
@@ -54,117 +54,21 @@ class Doctrine_Record_Filter extends Doctrine_Object
...
@@ -54,117 +54,21 @@ class Doctrine_Record_Filter extends Doctrine_Object
public
function
getRecord
()
public
function
getRecord
()
{
{
return
$this
->
_record
;
return
$this
->
_record
;
}
}
/**
/**
*
setDefaultValues
*
filterSet
*
sets the default values for records internal data
*
defines an implementation for filtering the set() method of Doctrine_Record
*
*
* @param boolean $overwrite whether or not to overwrite the already set values
* @param mixed $name name of the property or related component
* @return boolean
*/
*/
public
function
assignDefaultValues
(
$data
,
$overwrite
=
false
)
abstract
public
function
filterSet
(
$key
,
$value
)
{
{
}
$table
=
$this
->
_record
->
getTable
();
if
(
!
$table
->
hasDefaultValues
())
{
return
false
;
}
$modified
=
array
();
foreach
(
$data
as
$column
=>
$value
)
{
$default
=
$table
->
getDefaultValueOf
(
$column
);
if
(
$default
===
null
)
{
$default
=
self
::
$_null
;
}
if
(
$value
===
self
::
$_null
||
$overwrite
)
{
$this
->
_record
->
rawSet
(
$column
,
$default
);
$modified
[]
=
$column
;
$this
->
_record
->
state
(
Doctrine_Record
::
STATE_TDIRTY
);
}
}
$this
->
_record
->
setModified
(
$modified
);
}
/**
/**
*
prepareIdentifiers
*
filterGet
*
prepares identifiers for later use
*
defines an implementation for filtering the get() method of Doctrine_Record
*
*
* @param boolean $exists whether or not this record exists in persistent data store
* @param mixed $name name of the property or related component
* @return void
*/
*/
private
function
prepareIdentifiers
(
$exists
=
true
)
abstract
public
function
filterGet
(
$key
)
{
{
}
$id
=
$this
->
_table
->
getIdentifier
();
$this
->
_id
=
array
();
if
(
count
(
$id
)
>
1
)
{
foreach
(
$id
as
$name
)
{
if
(
$this
->
_data
[
$name
]
===
self
::
$_null
)
{
$this
->
_id
[
$name
]
=
null
;
}
else
{
$this
->
_id
[
$name
]
=
$this
->
_data
[
$name
];
}
}
}
else
{
if
(
isset
(
$this
->
_data
[
$id
])
&&
$this
->
_data
[
$id
]
!==
self
::
$_null
)
{
$this
->
_id
[
$id
]
=
$this
->
_data
[
$id
];
}
}
}
/**
* getPrepared
*
* returns an array of modified fields and values with data preparation
* adds column aggregation inheritance and converts Records into primary key values
*
* @param array $array
* @return array
*/
public
function
getPrepared
(
array
$array
=
array
())
{
$a
=
array
();
if
(
empty
(
$array
))
{
$array
=
$this
->
_modified
;
}
foreach
(
$array
as
$k
=>
$v
)
{
$type
=
$this
->
_table
->
getTypeOf
(
$v
);
if
(
$this
->
_data
[
$v
]
===
self
::
$_null
)
{
$a
[
$v
]
=
null
;
continue
;
}
switch
(
$type
)
{
case
'array'
:
case
'object'
:
$a
[
$v
]
=
serialize
(
$this
->
_data
[
$v
]);
break
;
case
'gzip'
:
$a
[
$v
]
=
gzcompress
(
$this
->
_data
[
$v
],
5
);
break
;
case
'boolean'
:
$a
[
$v
]
=
$this
->
getTable
()
->
getConnection
()
->
convertBooleans
(
$this
->
_data
[
$v
]);
break
;
case
'enum'
:
$a
[
$v
]
=
$this
->
_table
->
enumIndex
(
$v
,
$this
->
_data
[
$v
]);
break
;
default
:
if
(
$this
->
_data
[
$v
]
instanceof
Doctrine_Record
)
{
$this
->
_data
[
$v
]
=
$this
->
_data
[
$v
]
->
getIncremented
();
}
$a
[
$v
]
=
$this
->
_data
[
$v
];
}
}
$map
=
$this
->
_table
->
inheritanceMap
;
foreach
(
$map
as
$k
=>
$v
)
{
$old
=
$this
->
get
(
$k
,
false
);
if
((
string
)
$old
!==
(
string
)
$v
||
$old
===
null
)
{
$a
[
$k
]
=
$v
;
$this
->
_data
[
$k
]
=
$v
;
}
}
return
$a
;
}
}
}
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