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
a9e5a359
Commit
a9e5a359
authored
Oct 13, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin refactoring continues
parent
a73ce3a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
1 deletion
+59
-1
Plugin.php
lib/Doctrine/Plugin.php
+59
-1
No files found.
lib/Doctrine/Plugin.php
View file @
a9e5a359
...
...
@@ -98,7 +98,65 @@ class Doctrine_Plugin
{
return
$this
->
_options
;
}
/**
* generates foreign keys for the plugin table based on the owner table
*
* the foreign keys generated by this method can be used for
* setting the relations between the owner and the plugin classes
*
* @param Doctrine_Table $table the table object that owns the plugin
* @return array an array of foreign key definitions
*/
public
function
generateForeignKeys
(
Doctrine_Table
$table
)
{
$fk
=
array
();
foreach
((
array
)
$table
->
getIdentifier
()
as
$column
)
{
$def
=
$table
->
getDefinitionOf
(
$column
);
unset
(
$def
[
'autoincrement'
]);
unset
(
$def
[
'sequence'
]);
unset
(
$def
[
'primary'
]);
$col
=
strtolower
(
Doctrine
::
tableize
(
$table
->
getComponentName
())
.
'_'
.
$column
);
$def
[
'primary'
]
=
true
;
$fk
[
$col
]
=
$def
;
}
return
$fk
;
}
/**
* generates a relation array to given table
*
* this method can be used for generating the relation from the plugin
* table to the owner table
*
* @param Doctrine_Table $table the table object to construct the relation to
* @param array $foreignKeys an array of foreign keys
* @return array the generated relation array
*/
public
function
generateRelation
(
Doctrine_Table
$table
,
array
$foreignKeys
)
{
$local
=
(
count
(
$foreignKeys
)
>
1
)
?
array_keys
(
$foreignKeys
)
:
key
(
$foreignKeys
);
$relation
=
array
(
$table
->
getComponentName
()
=>
array
(
'local'
=>
$local
,
'foreign'
=>
$table
->
getIdentifier
(),
'onDelete'
=>
'CASCADE'
,
'onUpdate'
=>
'CASCADE'
));
return
$relation
;
}
/**
* generates the class definition for plugin class
*
* @param array $options plugin class options, keys representing the option names
* and values as option values
* @param array $columns the plugin class columns, keys representing the column names
* and values as column definitions
* @param array $relations the bound relations of the plugin class
* @return void
*/
public
function
generateClass
(
$options
,
$columns
,
$relations
)
{
$builder
=
new
Doctrine_Import_Builder
();
...
...
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