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
37cb86fe
Commit
37cb86fe
authored
Jan 21, 2010
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-260] Added support for better error reporting on ClassMetadata
parent
9cd0379f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
19 deletions
+56
-19
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+44
-19
MappingException.php
lib/Doctrine/ORM/Mapping/MappingException.php
+12
-0
No files found.
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
37cb86fe
...
@@ -136,15 +136,22 @@ class ClassMetadata extends ClassMetadataInfo
...
@@ -136,15 +136,22 @@ class ClassMetadata extends ClassMetadataInfo
*
*
* @param array $mapping The field mapping to validated & complete.
* @param array $mapping The field mapping to validated & complete.
* @return array The validated and completed field mapping.
* @return array The validated and completed field mapping.
*
* @throws MappingException
*/
*/
protected
function
_validateAndCompleteFieldMapping
(
array
&
$mapping
)
protected
function
_validateAndCompleteFieldMapping
(
array
&
$mapping
)
{
{
parent
::
_validateAndCompleteFieldMapping
(
$mapping
);
parent
::
_validateAndCompleteFieldMapping
(
$mapping
);
// Store ReflectionProperty of mapped field
// Store ReflectionProperty of mapped field
$refProp
=
$this
->
reflClass
->
getProperty
(
$mapping
[
'fieldName'
]);
try
{
$refProp
->
setAccessible
(
true
);
$refProp
=
$this
->
reflClass
->
getProperty
(
$mapping
[
'fieldName'
]);
$this
->
reflFields
[
$mapping
[
'fieldName'
]]
=
$refProp
;
$refProp
->
setAccessible
(
true
);
$this
->
reflFields
[
$mapping
[
'fieldName'
]]
=
$refProp
;
}
catch
(
\ReflectionException
$e
)
{
throw
MappingException
::
reflectionFailure
(
$this
->
name
,
$e
);
}
}
}
/**
/**
...
@@ -234,9 +241,15 @@ class ClassMetadata extends ClassMetadataInfo
...
@@ -234,9 +241,15 @@ class ClassMetadata extends ClassMetadataInfo
// Store ReflectionProperty of mapped field
// Store ReflectionProperty of mapped field
$sourceFieldName
=
$assocMapping
->
sourceFieldName
;
$sourceFieldName
=
$assocMapping
->
sourceFieldName
;
$refProp
=
$this
->
reflClass
->
getProperty
(
$sourceFieldName
);
$refProp
->
setAccessible
(
true
);
try
{
$this
->
reflFields
[
$sourceFieldName
]
=
$refProp
;
$refProp
=
$this
->
reflClass
->
getProperty
(
$sourceFieldName
);
$refProp
->
setAccessible
(
true
);
$this
->
reflFields
[
$sourceFieldName
]
=
$refProp
;
}
catch
(
\ReflectionException
$e
)
{
throw
MappingException
::
reflectionFailure
(
$this
->
name
,
$e
);
}
}
}
/**
/**
...
@@ -358,23 +371,35 @@ class ClassMetadata extends ClassMetadataInfo
...
@@ -358,23 +371,35 @@ class ClassMetadata extends ClassMetadataInfo
{
{
// Restore ReflectionClass and properties
// Restore ReflectionClass and properties
$this
->
reflClass
=
new
\ReflectionClass
(
$this
->
name
);
$this
->
reflClass
=
new
\ReflectionClass
(
$this
->
name
);
foreach
(
$this
->
fieldMappings
as
$field
=>
$mapping
)
{
foreach
(
$this
->
fieldMappings
as
$field
=>
$mapping
)
{
if
(
isset
(
$mapping
[
'inherited'
]))
{
try
{
$reflField
=
new
\ReflectionProperty
(
$mapping
[
'inherited'
],
$field
);
if
(
isset
(
$mapping
[
'inherited'
]))
{
}
else
{
$reflField
=
new
\ReflectionProperty
(
$mapping
[
'inherited'
],
$field
);
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
else
{
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
catch
(
\ReflectionException
$e
)
{
throw
MappingException
::
reflectionFailure
(
$this
->
name
,
$e
);
}
}
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
}
foreach
(
$this
->
associationMappings
as
$field
=>
$mapping
)
{
foreach
(
$this
->
associationMappings
as
$field
=>
$mapping
)
{
if
(
isset
(
$this
->
inheritedAssociationFields
[
$field
]))
{
try
{
$reflField
=
new
\ReflectionProperty
(
$this
->
inheritedAssociationFields
[
$field
],
$field
);
if
(
isset
(
$this
->
inheritedAssociationFields
[
$field
]))
{
}
else
{
$reflField
=
new
\ReflectionProperty
(
$this
->
inheritedAssociationFields
[
$field
],
$field
);
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
else
{
}
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
$reflField
->
setAccessible
(
true
);
}
$this
->
reflFields
[
$field
]
=
$reflField
;
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
catch
(
\ReflectionException
$e
)
{
throw
MappingException
::
reflectionFailure
(
$this
->
name
,
$e
);
}
}
}
//$this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
//$this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
...
...
lib/Doctrine/ORM/Mapping/MappingException.php
View file @
37cb86fe
...
@@ -103,4 +103,16 @@ class MappingException extends \Doctrine\Common\DoctrineException
...
@@ -103,4 +103,16 @@ class MappingException extends \Doctrine\Common\DoctrineException
{
{
return
new
self
(
"The mapping of field '
$fieldName
' is invalid."
);
return
new
self
(
"The mapping of field '
$fieldName
' is invalid."
);
}
}
/**
* Exception for reflection exceptions - adds the entity name,
* because there might be long classnames that will be shortened
* within the stacktrace
*
* @param string $entity The entity's name
* @param \ReflectionException $previousException
*/
public
static
function
reflectionFailure
(
$entity
,
\ReflectionException
$previousException
)
{
return
new
self
(
'An error occurred in '
.
$entity
,
$previousException
);
}
}
}
\ No newline at end of file
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