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
edcc8be2
Commit
edcc8be2
authored
Feb 24, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some smaller refactorings. started to replace the term 'template' with 'behavior'.
parent
c1c3f489
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
81 deletions
+85
-81
ClassMetadata.php
lib/Doctrine/ClassMetadata.php
+69
-31
Collection.php
lib/Doctrine/Collection.php
+3
-2
Import.php
lib/Doctrine/Data/Import.php
+1
-1
Mapper.php
lib/Doctrine/Mapper.php
+0
-16
Record.php
lib/Doctrine/Record.php
+9
-10
Parser.php
lib/Doctrine/Relation/Parser.php
+3
-21
No files found.
lib/Doctrine/ClassMetadata.php
View file @
edcc8be2
...
...
@@ -78,16 +78,16 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
protected
$_inheritanceType
=
Doctrine
::
INHERITANCETYPE_TABLE_PER_CLASS
;
/**
* An array containing all
template
s attached to the class.
* An array containing all
behavior
s attached to the class.
*
* @see Doctrine_Template
* @var array $_templates
* @todo Unify under 'Behaviors'.
*/
protected
$_
template
s
=
array
();
protected
$_
behavior
s
=
array
();
/**
* An array containing all
generators attached to this
class.
* An array containing all
behavior generators attached to the
class.
*
* @see Doctrine_Record_Generator
* @var array $_generators
...
...
@@ -242,7 +242,13 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
'collate'
=>
null
,
'indexes'
=>
array
(),
'checks'
=>
array
()
);
);
/**
* @var array $_invokedMethods method invoker cache
*/
protected
$_invokedMethods
=
array
();
/**
* Constructs a new metadata instance.
...
...
@@ -373,6 +379,17 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
->
_tableOptions
[
$name
];
}
public
function
getBehaviorForMethod
(
$method
)
{
return
(
isset
(
$this
->
_invokedMethods
[
$method
]))
?
$this
->
_invokedMethods
[
$method
]
:
false
;
}
public
function
addBehaviorMethod
(
$method
,
$behavior
)
{
$this
->
_invokedMethods
[
$method
]
=
$class
;
}
/**
* getOption
...
...
@@ -590,6 +607,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* Gets the names of all validators that are applied on a field.
*
* @param string The field name.
* @return array The names of all validators that are applied on the specified field.
*/
public
function
getFieldValidators
(
$fieldName
)
{
...
...
@@ -599,10 +618,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* hasDefaultValues
* returns true if this class has default values, otherwise false
* Checks whether the class mapped class has a default value on any field.
*
* @return boolean
* @return boolean
TRUE if the entity has a default value on any field, otherwise false.
*/
public
function
hasDefaultValues
()
{
...
...
@@ -630,6 +648,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Gets the identifier (primary key) field(s) of the mapped class.
*
* @return mixed
*/
public
function
getIdentifier
()
...
...
@@ -643,6 +663,10 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* Gets the type of the identifier (primary key) used by the mapped class. The type
* can be either "Doctrine::IDENTIFIER_NATURAL", "Doctrine::IDENTIFIER_AUTOINCREMENT",
* "Doctrine::IDENTIFIER_SEQUENCE" or "Doctrine::IDENTIFIER_COMPOSITE".
*
* @return integer
*/
public
function
getIdentifierType
()
...
...
@@ -650,6 +674,9 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
->
_identifierType
;
}
/**
* Sets the identifier type used by the mapped class.
*/
public
function
setIdentifierType
(
$type
)
{
$this
->
_identifierType
=
$type
;
...
...
@@ -658,12 +685,18 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
/**
* hasColumn
* @return boolean
* @deprecated
*/
public
function
hasColumn
(
$columnName
)
{
return
isset
(
$this
->
_mappedColumns
[
$columnName
]);
}
public
function
hasMappedColumn
(
$columnName
)
{
return
isset
(
$this
->
_mappedColumns
[
$columnName
]);
}
/**
* hasField
* @return boolean
...
...
@@ -864,6 +897,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* getDefinitionOf
*
* @return mixed array on success, false on failure
* @deprecated
*/
public
function
getDefinitionOf
(
$fieldName
)
{
...
...
@@ -871,17 +905,30 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
->
getColumnDefinition
(
$columnName
);
}
public
function
getMappingForField
(
$fieldName
)
{
$columnName
=
$this
->
getColumnName
(
$fieldName
);
return
$this
->
getColumnDefinition
(
$columnName
);
}
/**
* getTypeOf
*
* @return mixed string on success, false on failure
* @deprecated
*/
public
function
getTypeOf
(
$fieldName
)
{
return
$this
->
getTypeOfColumn
(
$this
->
getColumnName
(
$fieldName
));
}
public
function
getTypeOfField
(
$fieldName
)
{
return
$this
->
getTypeOfColumn
(
$this
->
getColumnName
(
$fieldName
));
}
/**
* getTypeOfColumn
*
...
...
@@ -994,15 +1041,15 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
/**
* get
Template
s
* returns all
templates attached to this table
* get
Behavior
s
* returns all
behaviors attached to the class.
*
* @return array an array containing all templates
* @todo Unify under 'Behaviors'
*/
public
function
get
Template
s
()
public
function
get
Behavior
s
()
{
return
$this
->
_
template
s
;
return
$this
->
_
behavior
s
;
}
/**
...
...
@@ -1308,29 +1355,29 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
* @return void
* @todo Unify under 'Behaviors'.
*/
public
function
get
Template
(
$templat
e
)
public
function
get
Behavior
(
$behaviorNam
e
)
{
if
(
!
isset
(
$this
->
_
templates
[
$templat
e
]))
{
throw
new
Doctrine_Table_Exception
(
'Template '
.
$
templat
e
.
' not loaded'
);
if
(
!
isset
(
$this
->
_
behaviors
[
$behaviorNam
e
]))
{
throw
new
Doctrine_Table_Exception
(
'Template '
.
$
behaviorNam
e
.
' not loaded'
);
}
return
$this
->
_
templates
[
$templat
e
];
return
$this
->
_
behaviors
[
$behaviorNam
e
];
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
has
Template
(
$templat
e
)
public
function
has
Behavior
(
$behaviorNam
e
)
{
return
isset
(
$this
->
_
templates
[
$templat
e
]);
return
isset
(
$this
->
_
behaviors
[
$behaviorNam
e
]);
}
/**
* @todo Unify under 'Behaviors'.
*/
public
function
add
Template
(
$templat
e
,
Doctrine_Template
$impl
)
public
function
add
Behavior
(
$behaviorNam
e
,
Doctrine_Template
$impl
)
{
$this
->
_
templates
[
$templat
e
]
=
$impl
;
$this
->
_
behaviors
[
$behaviorNam
e
]
=
$impl
;
return
$this
;
}
...
...
@@ -1599,7 +1646,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
$className
=
get_class
(
$tpl
);
$this
->
add
Template
(
$className
,
$tpl
);
$this
->
add
Behavior
(
$className
,
$tpl
);
$tpl
->
setTable
(
$this
);
$tpl
->
setUp
();
...
...
@@ -1639,17 +1686,6 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
}
}
/**
* Mixes a predefined behaviour into the class.
*
* @param string|object The name of the behavior or the behavior object.
* @todo Implementation.
*/
public
function
addBehavior
(
$behavior
)
{
// ...
}
/**
* Registers a custom mapper for the entity class.
*
...
...
@@ -1727,6 +1763,8 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab
return
$this
;
}
/**
*
*/
...
...
lib/Doctrine/Collection.php
View file @
edcc8be2
...
...
@@ -485,8 +485,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
public
function
add
(
$record
,
$key
=
null
)
{
if
(
!
$record
instanceO
f
Doctrine_Record
)
{
throw
new
Doctrine_Record_Exception
(
'Value variable in set is not an instance of Doctrine_Record'
);
if
(
!
$record
instanceo
f
Doctrine_Record
)
{
throw
new
Doctrine_Record_Exception
(
'Value variable in set is not an instance of Doctrine_Record
.
'
);
}
if
(
isset
(
$this
->
referenceField
))
{
...
...
@@ -527,6 +527,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
else
{
$this
->
data
[]
=
$record
;
}
return
true
;
}
...
...
lib/Doctrine/Data/Import.php
View file @
edcc8be2
...
...
@@ -178,7 +178,7 @@ class Doctrine_Data_Import extends Doctrine_Data
// This is simple here to get the templates present for this model
// better way?
$obj
=
new
$className
(
null
,
true
);
$templates
=
array_keys
(
$obj
->
getTable
()
->
get
Template
s
());
$templates
=
array_keys
(
$obj
->
getTable
()
->
get
Behavior
s
());
if
(
in_array
(
'Doctrine_Template_NestedSet'
,
$templates
))
{
$nestedSets
[
$className
][]
=
$data
;
...
...
lib/Doctrine/Mapper.php
View file @
edcc8be2
...
...
@@ -68,11 +68,6 @@ class Doctrine_Mapper extends Doctrine_Configurable implements Countable
*/
protected
$_repository
;
/**
* @var array $_invokedMethods method invoker cache
*/
protected
$_invokedMethods
=
array
();
/**
* Constructs a new mapper.
...
...
@@ -95,17 +90,6 @@ class Doctrine_Mapper extends Doctrine_Configurable implements Countable
}
}
public
function
getMethodOwner
(
$method
)
{
return
(
isset
(
$this
->
_invokedMethods
[
$method
]))
?
$this
->
_invokedMethods
[
$method
]
:
false
;
}
public
function
setMethodOwner
(
$method
,
$class
)
{
$this
->
_invokedMethods
[
$method
]
=
$class
;
}
/**
* export
* exports this table to database based on column and option definitions
...
...
lib/Doctrine/Record.php
View file @
edcc8be2
...
...
@@ -1682,7 +1682,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
public
function
revert
(
$version
)
{
$data
=
$this
->
_table
->
get
Template
(
'Doctrine_Template_Versionable'
)
->
get
Behavior
(
'Doctrine_Template_Versionable'
)
->
getAuditLog
()
->
getVersion
(
$this
,
$version
);
...
...
@@ -1841,17 +1841,16 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
public
function
__call
(
$method
,
$args
)
{
if
((
$
template
=
$this
->
_mapper
->
getMethodOwner
(
$method
))
!==
false
)
{
$
template
->
setInvoker
(
$this
);
return
call_user_func_array
(
array
(
$
template
,
$method
),
$args
);
if
((
$
behavior
=
$this
->
_table
->
getBehaviorForMethod
(
$method
))
!==
false
)
{
$
behavior
->
setInvoker
(
$this
);
return
call_user_func_array
(
array
(
$
behavior
,
$method
),
$args
);
}
foreach
(
$this
->
_mapper
->
getTable
()
->
getTemplates
()
as
$template
)
{
if
(
method_exists
(
$template
,
$method
))
{
$template
->
setInvoker
(
$this
);
$this
->
_mapper
->
setMethodOwner
(
$method
,
$template
);
return
call_user_func_array
(
array
(
$template
,
$method
),
$args
);
foreach
(
$this
->
_table
->
getBehaviors
()
as
$behavior
)
{
if
(
method_exists
(
$behavior
,
$method
))
{
$behavior
->
setInvoker
(
$this
);
$this
->
_table
->
addBehaviorMethod
(
$method
,
$behavior
);
return
call_user_func_array
(
array
(
$behavior
,
$method
),
$args
);
}
}
...
...
lib/Doctrine/Relation/Parser.php
View file @
edcc8be2
...
...
@@ -136,12 +136,12 @@ class Doctrine_Relation_Parser
$this
->
getRelations
();
return
$this
->
getRelation
(
$alias
,
false
);
}
else
{
try
{
/*
try {
throw new Exception();
} catch (Exception $e) {
//echo "" . "<br />";
///echo $e->getTraceAsString() . "<br /><br /><br />";
}
}
*/
throw
new
Doctrine_Relation_Exception
(
"Unknown relation '
$alias
'."
);
}
}
...
...
@@ -171,19 +171,7 @@ class Doctrine_Relation_Parser
$def
=
$this
->
completeAssocDefinition
(
$def
);
$localClasses
=
array_merge
(
$this
->
_table
->
getOption
(
'parents'
),
array
(
$this
->
_table
->
getClassName
()));
// if the two many-many related components share the same table, we need
// custom relation names to distinguish the relations.
/*if ($this->_table->getInheritanceType() == Doctrine::INHERITANCETYPE_SINGLE_TABLE &&
in_array($def['class'], $this->_table->getOption('subclasses'))) {
if ( ! isset($def['refRelationName']) || ! isset($def['refReverseRelationName'])) {
throw new Doctrine_Relation_Exception("Incomplete relation. Many-to-many relations between "
. "classes that share the same table (single table inheritance) need to specify "
. "a 'refRelationName' and a 'refReverseRelationName' to distinguish relations.");
}
$relationName = $def['refRelationName'];
} else {*/
$relationName
=
$def
[
'refClass'
];
//}
$relationName
=
$def
[
'refClass'
];
if
(
!
isset
(
$this
->
_pending
[
$relationName
])
&&
!
isset
(
$this
->
_relations
[
$relationName
]))
{
$this
->
_completeManyToManyRelation
(
$def
);
...
...
@@ -222,12 +210,7 @@ class Doctrine_Relation_Parser
$identifierColumnNames
=
$this
->
_table
->
getIdentifierColumnNames
();
$idColumnName
=
array_pop
(
$identifierColumnNames
);
// if the two many-many related components shared the same table, we need a relation name
// to distinguish the relations.
$relationName
=
$def
[
'refClass'
];
/*if (isset($def['refRelationName'])) {
$relationName .= ' as ' . $def['refRelationName'];
}*/
// add a relation pointing from the intermediary table to the table of this parser
$parser
=
$def
[
'refTable'
]
->
getRelationParser
();
...
...
@@ -416,7 +399,6 @@ class Doctrine_Relation_Parser
{
$conn
=
$this
->
_table
->
getConnection
();
$def
[
'table'
]
=
$this
->
getImpl
(
$def
,
'class'
);
//$def['class'] = $def['table']->getComponentName();
$def
[
'localTable'
]
=
$this
->
_table
;
$foreignClasses
=
array_merge
(
$def
[
'table'
]
->
getOption
(
'parents'
),
array
(
$def
[
'class'
]));
...
...
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