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
bfa3ef56
Commit
bfa3ef56
authored
Sep 21, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
f787a29b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
23 deletions
+97
-23
Record.php
lib/Doctrine/Record.php
+22
-2
Compound.php
lib/Doctrine/Record/Filter/Compound.php
+38
-6
Table.php
lib/Doctrine/Table.php
+37
-15
No files found.
lib/Doctrine/Record.php
View file @
bfa3ef56
...
...
@@ -866,7 +866,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
try
{
$this
->
coreSetRelated
(
$name
,
$value
);
}
catch
(
Doctrine_Table_Exception
$e
)
{
throw
new
Doctrine_Record_Exception
(
"Unknown property / related component '
$name
'."
);
foreach
(
$this
->
_table
->
getFilters
()
as
$filter
)
{
if
((
$value
=
$filter
->
filterSet
(
$this
,
$name
,
$value
))
!==
null
)
{
return
$value
;
}
}
}
}
}
...
...
@@ -1310,6 +1314,17 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
{
return
isset
(
$this
->
_references
[
$name
]);
}
/**
* reference
*
* @param string $name
*/
public
function
reference
(
$name
)
{
if
(
isset
(
$this
->
_references
[
$name
]))
{
return
$this
->
_references
[
$name
];
}
}
/**
* obtainReference
*
...
...
@@ -1457,6 +1472,11 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$this
->
_node
;
}
public
function
unshiftFilter
(
Doctrine_Record_Filter
$filter
)
{
return
$this
->
_table
->
unshiftFilter
(
$filter
);
}
/**
* revert
* reverts this record to given version, this method only works if versioning plugin
...
...
@@ -1482,7 +1502,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
return
$this
;
}
/**
*
removeLinks
*
unlink
* removes links from this record to given records
* if no ids are given, it removes all links
*
...
...
lib/Doctrine/Record/Filter/Compound.php
View file @
bfa3ef56
...
...
@@ -35,15 +35,16 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
protected
$_aliases
=
array
();
public
function
__construct
(
array
$aliases
)
{
$this
->
_aliases
=
$aliases
;
}
public
function
init
()
{
// check that all aliases exist
foreach
(
$aliases
as
$alias
)
{
foreach
(
$
this
->
_
aliases
as
$alias
)
{
$this
->
_table
->
getRelation
(
$alias
);
}
$this
->
_aliases
=
$aliases
;
}
/**
* filterSet
* defines an implementation for filtering the set() method of Doctrine_Record
...
...
@@ -52,8 +53,26 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
*/
public
function
filterSet
(
Doctrine_Record
$record
,
$name
,
$value
)
{
foreach
(
$this
->
_aliases
as
$alias
)
{
if
(
!
$record
->
exists
())
{
if
(
isset
(
$record
[
$alias
][
$name
]))
{
$record
[
$alias
][
$name
]
=
$value
;
return
$record
;
}
}
else
{
// we do not want to execute N + 1 queries here, hence we cannot use get()
if
((
$ref
=
$record
->
reference
(
$alias
))
!==
null
)
{
if
(
isset
(
$ref
[
$name
]))
{
$ref
[
$name
]
=
$value
;
}
return
$record
;
}
}
}
}
/**
* filterGet
* defines an implementation for filtering the get() method of Doctrine_Record
...
...
@@ -62,6 +81,19 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
*/
public
function
filterGet
(
Doctrine_Record
$record
,
$name
)
{
foreach
(
$this
->
_aliases
as
$alias
)
{
if
(
!
$record
->
exists
())
{
if
(
isset
(
$record
[
$alias
][
$name
]))
{
return
$record
[
$alias
][
$name
];
}
}
else
{
// we do not want to execute N + 1 queries here, hence we cannot use get()
if
((
$ref
=
$record
->
reference
(
$alias
))
!==
null
)
{
if
(
isset
(
$ref
[
$name
]))
{
return
$ref
[
$name
];
}
}
}
}
}
}
lib/Doctrine/Table.php
View file @
bfa3ef56
...
...
@@ -129,20 +129,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* -- versioning
*/
protected
$options
=
array
(
'name'
=>
null
,
'tableName'
=>
null
,
'sequenceName'
=>
null
,
'inheritanceMap'
=>
array
(),
'enumMap'
=>
array
(),
'engine'
=>
null
,
'charset'
=>
null
,
'collation'
=>
null
,
'treeImpl'
=>
null
,
'treeOptions'
=>
null
,
'indexes'
=>
array
(),
'parents'
=>
array
(),
'versioning'
=>
null
,
);
protected
$options
=
array
(
'name'
=>
null
,
'tableName'
=>
null
,
'sequenceName'
=>
null
,
'inheritanceMap'
=>
array
(),
'enumMap'
=>
array
(),
'engine'
=>
null
,
'charset'
=>
null
,
'collation'
=>
null
,
'treeImpl'
=>
null
,
'treeOptions'
=>
null
,
'indexes'
=>
array
(),
'parents'
=>
array
(),
'versioning'
=>
null
,
);
/**
* @var Doctrine_Tree $tree tree object associated with this table
*/
...
...
@@ -154,7 +154,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
/**
* @var array $_templates an array containing all templates attached to this table
*/
protected
$_templates
=
array
();
protected
$_templates
=
array
();
/**
* @var array $_filters an array containing all record filters attached to this table
*/
protected
$_filters
=
array
();
/**
...
...
@@ -284,6 +289,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
$this
->
isTree
())
{
$this
->
getTree
()
->
setUp
();
}
$this
->
_filters
[]
=
new
Doctrine_Record_Filter_Standard
();
$this
->
_repository
=
new
Doctrine_Table_Repository
(
$this
);
}
/**
...
...
@@ -1280,6 +1286,22 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public
function
addTemplate
(
$template
,
Doctrine_Template
$impl
)
{
$this
->
_templates
[
$template
]
=
$impl
;
return
$this
;
}
public
function
unshiftFilter
(
Doctrine_Record_Filter
$filter
)
{
$filter
->
setTable
(
$this
);
$filter
->
init
();
array_unshift
(
$this
->
_filters
,
$filter
);
return
$this
;
}
public
function
getFilters
()
{
return
$this
->
_filters
;
}
/**
* returns a string representation of this object
...
...
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