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
a0857060
Commit
a0857060
authored
Oct 05, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to loading models and made it so Builder can generate abstract classes.
parent
e7e153d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
30 deletions
+18
-30
Doctrine.php
lib/Doctrine.php
+8
-18
Builder.php
lib/Doctrine/Import/Builder.php
+10
-12
No files found.
lib/Doctrine.php
View file @
a0857060
...
@@ -483,24 +483,14 @@ final class Doctrine
...
@@ -483,24 +483,14 @@ final class Doctrine
// and currently declared classes
// and currently declared classes
foreach
(
$classes
as
$name
)
{
foreach
(
$classes
as
$name
)
{
$class
=
new
ReflectionClass
(
$name
);
$class
=
new
ReflectionClass
(
$name
);
$conn
=
Doctrine_Manager
::
getInstance
()
->
getConnectionForComponent
(
$name
);
// check if class is an instance of Doctrine_Record and not abstract
// class must have method setTableDefinition (to avoid non-Record subclasses like symfony's sfDoctrineRecord)
// we have to recursively iterate through the class parents just to be sure that the classes using for example
// column aggregation inheritance are properly exported to database
while
(
$class
->
isAbstract
()
||
!
$class
->
isSubclassOf
(
$parent
)
||
!
$class
->
hasMethod
(
'setTableDefinition'
)
||
(
$class
->
hasMethod
(
'setTableDefinition'
)
&&
$class
->
getMethod
(
'setTableDefinition'
)
->
getDeclaringClass
()
->
getName
()
!==
$class
->
getName
()))
{
$class
=
$class
->
getParentClass
();
if
(
$class
===
false
)
{
break
;
}
}
if
(
$class
===
false
)
{
// Skip the following classes
// - abstract classes
// - not a subclass of Doctrine_Record
// - don't have a setTableDefinition method
if
(
$class
->
isAbstract
()
||
!
$class
->
isSubClassOf
(
$parent
)
||
!
$class
->
hasMethod
(
'setTableDefinition'
))
{
continue
;
continue
;
}
}
...
...
lib/Doctrine/Import/Builder.php
View file @
a0857060
...
@@ -113,7 +113,7 @@ class Doctrine_Import_Builder
...
@@ -113,7 +113,7 @@ class Doctrine_Import_Builder
/**
/**
* This class has been auto-generated by the Doctrine ORM Framework
* This class has been auto-generated by the Doctrine ORM Framework
*/
*/
class
%
s
extends
%
s
%
s
class
%
s
extends
%
s
{
{
%
s
%
s
%
s
%
s
...
@@ -273,18 +273,14 @@ END;
...
@@ -273,18 +273,14 @@ END;
throw
new
Doctrine_Import_Builder_Exception
(
'Missing class name.'
);
throw
new
Doctrine_Import_Builder_Exception
(
'Missing class name.'
);
}
}
$abstract
=
isset
(
$options
[
'abstract'
])
?
'abstract '
:
null
;
$className
=
$options
[
'className'
];
$className
=
$options
[
'className'
];
$extends
=
isset
(
$options
[
'inheritance'
][
'extends'
])
?
$options
[
'inheritance'
][
'extends'
]
:
'Doctrine_Record'
;
$extends
=
isset
(
$options
[
'inheritance'
][
'extends'
])
?
$options
[
'inheritance'
][
'extends'
]
:
'Doctrine_Record'
;
$definition
=
!
isset
(
$options
[
'no_definition'
])
?
$this
->
buildTableDefinition
(
$options
,
$columns
,
$relations
)
:
null
;
$setUp
=
!
isset
(
$options
[
'no_definition'
])
?
$this
->
buildSetUp
(
$options
,
$columns
,
$relations
)
:
null
;
if
(
!
isset
(
$options
[
'no_definition'
]))
{
$content
=
sprintf
(
self
::
$tpl
,
$abstract
,
$definition
=
$this
->
buildTableDefinition
(
$options
,
$columns
,
$relations
);
$className
,
$setUp
=
$this
->
buildSetUp
(
$options
,
$columns
,
$relations
);
}
else
{
$definition
=
null
;
$setUp
=
null
;
}
$content
=
sprintf
(
self
::
$tpl
,
$className
,
$extends
,
$extends
,
$definition
,
$definition
,
$setUp
);
$setUp
);
...
@@ -313,7 +309,8 @@ END;
...
@@ -313,7 +309,8 @@ END;
if
(
$this
->
generateBaseClasses
())
{
if
(
$this
->
generateBaseClasses
())
{
//if (!file_exists($options['fileName'])) {
// We only want to generate this one if it doesn't already exist
if
(
!
file_exists
(
$options
[
'fileName'
]))
{
$optionsBak
=
$options
;
$optionsBak
=
$options
;
unset
(
$options
[
'tableName'
]);
unset
(
$options
[
'tableName'
]);
...
@@ -321,7 +318,7 @@ END;
...
@@ -321,7 +318,7 @@ END;
$this
->
writeDefinition
(
$options
,
array
(),
array
());
$this
->
writeDefinition
(
$options
,
array
(),
array
());
$options
=
$optionsBak
;
$options
=
$optionsBak
;
//
}
}
$generatedPath
=
$this
->
path
.
DIRECTORY_SEPARATOR
.
$this
->
baseClassesDirectory
;
$generatedPath
=
$this
->
path
.
DIRECTORY_SEPARATOR
.
$this
->
baseClassesDirectory
;
...
@@ -330,6 +327,7 @@ END;
...
@@ -330,6 +327,7 @@ END;
}
}
$options
[
'className'
]
=
'Base'
.
$options
[
'className'
];
$options
[
'className'
]
=
'Base'
.
$options
[
'className'
];
$options
[
'abstract'
]
=
true
;
$options
[
'fileName'
]
=
$generatedPath
.
DIRECTORY_SEPARATOR
.
$options
[
'className'
]
.
$this
->
suffix
;
$options
[
'fileName'
]
=
$generatedPath
.
DIRECTORY_SEPARATOR
.
$options
[
'className'
]
.
$this
->
suffix
;
$this
->
writeDefinition
(
$options
,
$columns
,
$relations
);
$this
->
writeDefinition
(
$options
,
$columns
,
$relations
);
...
...
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