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
3a58e144
Commit
3a58e144
authored
Mar 28, 2010
by
guilhermeblanco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Fixed issue with namespaces of entities in EntityGenerator
parent
21c1952b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
EntityGenerator.php
lib/Doctrine/ORM/Tools/EntityGenerator.php
+25
-25
No files found.
lib/Doctrine/ORM/Tools/EntityGenerator.php
View file @
3a58e144
...
...
@@ -136,7 +136,7 @@ public function <methodName>()
* Generate and write entity classes for the given array of ClassMetadataInfo instances
*
* @param array $metadatas
* @param string $outputDirectory
* @param string $outputDirectory
* @return void
*/
public
function
generate
(
array
$metadatas
,
$outputDirectory
)
...
...
@@ -150,7 +150,7 @@ public function <methodName>()
* Generated and write entity class to disk for the given ClassMetadataInfo instance
*
* @param ClassMetadataInfo $metadata
* @param string $outputDirectory
* @param string $outputDirectory
* @return void
*/
public
function
writeEntityClass
(
ClassMetadataInfo
$metadata
,
$outputDirectory
)
...
...
@@ -171,7 +171,7 @@ public function <methodName>()
// If entity doesn't exist or we're re-generating the entities entirely
if
(
$this
->
_isNew
||
(
!
$this
->
_isNew
&&
$this
->
_regenerateEntityIfExists
))
{
file_put_contents
(
$path
,
$this
->
generateEntityClass
(
$metadata
));
// If entity exists and we're allowed to update the entity class
}
else
if
(
!
$this
->
_isNew
&&
$this
->
_updateEntityIfExists
)
{
file_put_contents
(
$path
,
$this
->
generateUpdatedEntityClass
(
$metadata
,
$path
));
...
...
@@ -181,7 +181,7 @@ public function <methodName>()
/**
* Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance
*
* @param ClassMetadataInfo $metadata
* @param ClassMetadataInfo $metadata
* @return string $code
*/
public
function
generateEntityClass
(
ClassMetadataInfo
$metadata
)
...
...
@@ -209,8 +209,8 @@ public function <methodName>()
/**
* Generate the updated code for the given ClassMetadataInfo and entity at path
*
* @param ClassMetadataInfo $metadata
* @param string $path
* @param ClassMetadataInfo $metadata
* @param string $path
* @return string $code;
*/
public
function
generateUpdatedEntityClass
(
ClassMetadataInfo
$metadata
,
$path
)
...
...
@@ -218,7 +218,7 @@ public function <methodName>()
$currentCode
=
file_get_contents
(
$path
);
$body
=
$this
->
_generateEntityBody
(
$metadata
);
$last
=
strrpos
(
$currentCode
,
'}'
);
$code
=
substr
(
$currentCode
,
0
,
$last
)
.
$body
.
'}'
;
return
$code
;
...
...
@@ -227,7 +227,7 @@ public function <methodName>()
/**
* Set the number of spaces the exported class should have
*
* @param integer $numSpaces
* @param integer $numSpaces
* @return void
*/
public
function
setNumSpaces
(
$numSpaces
)
...
...
@@ -239,7 +239,7 @@ public function <methodName>()
/**
* Set the extension to use when writing php files to disk
*
* @param string $extension
* @param string $extension
* @return void
*/
public
function
setExtension
(
$extension
)
...
...
@@ -260,7 +260,7 @@ public function <methodName>()
/**
* Set whether or not to generate annotations for the entity
*
* @param bool $bool
* @param bool $bool
* @return void
*/
public
function
setGenerateAnnotations
(
$bool
)
...
...
@@ -271,7 +271,7 @@ public function <methodName>()
/**
* Set whether or not to try and update the entity if it already exists
*
* @param bool $bool
* @param bool $bool
* @return void
*/
public
function
setUpdateEntityIfExists
(
$bool
)
...
...
@@ -386,7 +386,7 @@ public function <methodName>()
private
function
_getClassToExtendNamespace
()
{
$refl
=
new
\ReflectionClass
(
$this
->
_getClassToExtend
());
return
$refl
->
getNamespaceName
()
?
$refl
->
getNamespaceName
()
:
$refl
->
getShortName
();
return
$refl
->
getNamespaceName
()
?
$refl
->
getNamespaceName
()
:
$refl
->
getShortName
();
}
private
function
_getClassName
(
ClassMetadataInfo
$metadata
)
...
...
@@ -527,15 +527,15 @@ public function <methodName>()
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'add'
,
$associationMapping
->
sourceFieldName
,
$associationMapping
->
targetEntityName
))
{
$methods
[]
=
$code
;
}
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'get'
,
$associationMapping
->
sourceFieldName
,
'Doctrine\Common\Collections\Collection'
))
{
$methods
[]
=
$code
;
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'get'
,
$associationMapping
->
sourceFieldName
,
'
\
Doctrine\Common\Collections\Collection'
))
{
$methods
[]
=
$code
;
}
}
}
else
if
(
$associationMapping
instanceof
\Doctrine\ORM\Mapping\ManyToManyMapping
)
{
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'add'
,
$associationMapping
->
sourceFieldName
,
$associationMapping
->
targetEntityName
))
{
$methods
[]
=
$code
;
}
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'get'
,
$associationMapping
->
sourceFieldName
,
'Doctrine\Common\Collections\Collection'
))
{
if
(
$code
=
$this
->
_generateEntityStubMethod
(
$metadata
,
'get'
,
$associationMapping
->
sourceFieldName
,
'
\
Doctrine\Common\Collections\Collection'
))
{
$methods
[]
=
$code
;
}
}
...
...
@@ -600,7 +600,7 @@ public function <methodName>()
$variableType
=
$typeHint
?
$typeHint
.
' '
:
null
;
$types
=
\Doctrine\DBAL\Types\Type
::
getTypesMap
();
$methodTypeHint
=
$typeHint
&&
!
isset
(
$types
[
$typeHint
])
?
$typeHint
.
' '
:
null
;
$methodTypeHint
=
$typeHint
&&
!
isset
(
$types
[
$typeHint
])
?
'\\'
.
$typeHint
.
' '
:
null
;
$replacements
=
array
(
'<description>'
=>
ucfirst
(
$type
)
.
' '
.
$fieldName
,
...
...
@@ -691,7 +691,7 @@ public function <methodName>()
if
(
$associationMapping
->
isCascadeDetach
)
$cascades
[]
=
'"detach"'
;
if
(
$associationMapping
->
isCascadeMerge
)
$cascades
[]
=
'"merge"'
;
if
(
$associationMapping
->
isCascadeRefresh
)
$cascades
[]
=
'"refresh"'
;
$typeOptions
[]
=
'cascade={'
.
implode
(
','
,
$cascades
)
.
'}'
;
$typeOptions
[]
=
'cascade={'
.
implode
(
','
,
$cascades
)
.
'}'
;
}
if
(
isset
(
$associationMapping
->
orphanRemoval
)
&&
$associationMapping
->
orphanRemoval
)
{
$typeOptions
[]
=
'orphanRemoval='
.
(
$associationMapping
->
orphanRemoval
?
'true'
:
'false'
);
...
...
@@ -739,7 +739,7 @@ public function <methodName>()
if
(
isset
(
$associationMapping
->
orderBy
))
{
$lines
[]
=
$this
->
_spaces
.
' * @OrderBy({'
;
foreach
(
$associationMapping
->
orderBy
as
$name
=>
$direction
)
{
$lines
[]
=
$this
->
_spaces
.
' * "'
.
$name
.
'"="'
.
$direction
.
'",'
;
$lines
[]
=
$this
->
_spaces
.
' * "'
.
$name
.
'"="'
.
$direction
.
'",'
;
}
$lines
[
count
(
$lines
)
-
1
]
=
substr
(
$lines
[
count
(
$lines
)
-
1
],
0
,
strlen
(
$lines
[
count
(
$lines
)
-
1
])
-
1
);
$lines
[]
=
$this
->
_spaces
.
' * })'
;
...
...
@@ -846,11 +846,11 @@ public function <methodName>()
case
ClassMetadataInfo
::
INHERITANCE_TYPE_JOINED
:
return
'JOINED'
;
break
;
case
ClassMetadataInfo
::
INHERITANCE_TYPE_SINGLE_TABLE
:
return
'SINGLE_TABLE'
;
break
;
case
ClassMetadataInfo
::
INHERITANCE_TYPE_TABLE_PER_CLASS
:
return
'PER_CLASS'
;
break
;
...
...
@@ -864,11 +864,11 @@ public function <methodName>()
case
ClassMetadataInfo
::
CHANGETRACKING_DEFERRED_IMPLICIT
:
return
'DEFERRED_IMPLICIT'
;
break
;
case
ClassMetadataInfo
::
CHANGETRACKING_DEFERRED_EXPLICIT
:
return
'DEFERRED_EXPLICIT'
;
break
;
case
ClassMetadataInfo
::
CHANGETRACKING_NOTIFY
:
return
'NOTIFY'
;
break
;
...
...
@@ -882,15 +882,15 @@ public function <methodName>()
case
ClassMetadataInfo
::
GENERATOR_TYPE_AUTO
:
return
'AUTO'
;
break
;
case
ClassMetadataInfo
::
GENERATOR_TYPE_SEQUENCE
:
return
'SEQUENCE'
;
break
;
case
ClassMetadataInfo
::
GENERATOR_TYPE_TABLE
:
return
'TABLE'
;
break
;
case
ClassMetadataInfo
::
GENERATOR_TYPE_IDENTITY
:
return
'IDENTITY'
;
break
;
...
...
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