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
0f79ed1d
Commit
0f79ed1d
authored
Oct 14, 2007
by
pookey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improvement to option handling, and added accessor generators
parent
6e020bef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
10 deletions
+34
-10
Builder.php
lib/Doctrine/Import/Builder.php
+34
-10
No files found.
lib/Doctrine/Import/Builder.php
View file @
0f79ed1d
...
...
@@ -117,11 +117,29 @@ class Doctrine_Import_Builder
{
%
s
%
s
%
s
}
END
;
}
/*
* Build the accessors
*
* @param string $table
* @param array $tableColumns
*/
public
function
buildAccessors
(
array
$options
,
array
$columns
)
{
$ret
=
''
;
foreach
(
$columns
as
$name
=>
$column
)
{
$ret
.=
"
\t
public function get
{
$name
}
() {\n"
;
$ret
.=
"
\t\t
return
\$
this->
{
$name
}
;
\n
"
;
$ret
.=
"
\t
}
\n
"
;
}
return
$ret
;
}
/*
* Build the table definition of a Doctrine_Record object
*
...
...
@@ -253,10 +271,9 @@ END;
public
function
buildSetUp
(
array
$options
,
array
$columns
,
array
$relations
)
{
$ret
=
array
();
$i
=
0
;
if
(
isset
(
$options
[
'inheritance'
][
'extends'
])
&&
!
isset
(
$options
[
'override_parent'
]
))
{
if
(
!
(
isset
(
$options
[
'override_parent'
])
&&
$options
[
'override_parent'
]
==
true
))
{
$ret
[
$i
]
=
"
\t\t\t\t
parent::setUp();"
;
$i
++
;
}
...
...
@@ -327,18 +344,27 @@ END;
if
(
!
isset
(
$options
[
'className'
]))
{
throw
new
Doctrine_Import_Builder_Exception
(
'Missing class name.'
);
}
$abstract
=
isset
(
$options
[
'abstract'
])
?
'abstract '
:
null
;
$abstract
=
isset
(
$options
[
'abstract'
])
&&
$options
[
'abstract'
]
==
true
?
'abstract '
:
null
;
$className
=
$options
[
'className'
];
$extends
=
isset
(
$options
[
'inheritance'
][
'extends'
])
?
$options
[
'inheritance'
][
'extends'
]
:
'Doctrine_Record'
;
$definition
=
!
isset
(
$options
[
'no_definition'
])
?
$this
->
buildTableDefinition
(
$options
,
$columns
,
$relations
,
$indexes
)
:
null
;
$setUp
=
!
isset
(
$options
[
'no_definition'
])
?
$this
->
buildSetUp
(
$options
,
$columns
,
$relations
)
:
null
;
if
(
isset
(
$options
[
'no_definition'
])
&&
$options
[
'no_definition'
]
==
false
)
{
$definition
=
null
;
$setUp
=
null
;
}
else
{
$definition
=
$this
->
buildTableDefinition
(
$options
,
$columns
,
$relations
,
$indexes
);
$setUp
=
$this
->
buildSetUp
(
$options
,
$columns
,
$relations
);
}
$accessors
=
isset
(
$options
[
'generate_accessors'
])
&&
$options
[
'generate_accessors'
]
==
true
?
$this
->
buildAccessors
(
$options
,
$columns
)
:
null
;
$content
=
sprintf
(
self
::
$tpl
,
$abstract
,
$className
,
$extends
,
$definition
,
$setUp
);
$setUp
,
$accessors
);
return
$content
;
}
...
...
@@ -397,7 +423,6 @@ END;
public
function
writeDefinition
(
array
$options
,
array
$columns
,
array
$relations
=
array
(),
array
$indexes
=
array
())
{
$content
=
$this
->
buildDefinition
(
$options
,
$columns
,
$relations
,
$indexes
);
$code
=
"<?php
\n
"
;
if
(
isset
(
$options
[
'requires'
]))
{
...
...
@@ -409,7 +434,6 @@ END;
$code
.=
"require_once('"
.
$require
.
"');"
;
}
}
$code
.=
PHP_EOL
.
$content
;
$bytes
=
file_put_contents
(
$options
[
'fileName'
],
$code
);
...
...
@@ -418,4 +442,4 @@ END;
throw
new
Doctrine_Import_Builder_Exception
(
"Couldn't write file "
.
$options
[
'fileName'
]);
}
}
}
\ 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