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
e2d8a916
Commit
e2d8a916
authored
Jan 27, 2008
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed class name in comments
parent
ebbfcf4c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
147 deletions
+147
-147
Migration.php
lib/Doctrine/Builder/Migration.php
+42
-42
Record.php
lib/Doctrine/Builder/Record.php
+105
-105
No files found.
lib/Doctrine/Builder/Migration.php
View file @
e2d8a916
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
*/
*/
/**
/**
* Doctrine_
Migration_Builder
* Doctrine_
Builder_Migration
*
*
* @package Doctrine
* @package Doctrine
* @subpackage Builder
* @subpackage Builder
...
@@ -35,7 +35,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
...
@@ -35,7 +35,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
{
{
/**
/**
* migrationsPath
* migrationsPath
*
*
* The path to your migration classes directory
* The path to your migration classes directory
*
*
* @var string
* @var string
...
@@ -44,7 +44,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
...
@@ -44,7 +44,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
/**
/**
* suffix
* suffix
*
*
* File suffix to use when writing class definitions
* File suffix to use when writing class definitions
*
*
* @var string $suffix
* @var string $suffix
...
@@ -70,7 +70,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
...
@@ -70,7 +70,7 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
if
(
$migrationsPath
)
{
if
(
$migrationsPath
)
{
$this
->
setMigrationsPath
(
$migrationsPath
);
$this
->
setMigrationsPath
(
$migrationsPath
);
}
}
$this
->
_loadTemplate
();
$this
->
_loadTemplate
();
}
}
...
@@ -99,12 +99,12 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
...
@@ -99,12 +99,12 @@ class Doctrine_Builder_Migration extends Doctrine_Builder
/**
/**
* loadTemplate
* loadTemplate
*
*
* Loads the class template used for generating classes
* Loads the class template used for generating classes
*
*
* @return void
* @return void
*/
*/
protected
function
_loadTemplate
()
protected
function
_loadTemplate
()
{
{
if
(
isset
(
self
::
$_tpl
))
{
if
(
isset
(
self
::
$_tpl
))
{
return
;
return
;
...
@@ -139,18 +139,18 @@ END;
...
@@ -139,18 +139,18 @@ END;
$directory
=
sys_get_temp_dir
()
.
DIRECTORY_SEPARATOR
.
'tmp_doctrine_models'
;
$directory
=
sys_get_temp_dir
()
.
DIRECTORY_SEPARATOR
.
'tmp_doctrine_models'
;
Doctrine
::
generateModelsFromDb
(
$directory
);
Doctrine
::
generateModelsFromDb
(
$directory
);
$result
=
$this
->
generateMigrationsFromModels
(
$directory
);
$result
=
$this
->
generateMigrationsFromModels
(
$directory
);
Doctrine_Lib
::
removeDirectories
(
$directory
);
Doctrine_Lib
::
removeDirectories
(
$directory
);
return
$result
;
return
$result
;
}
}
/**
/**
* generateMigrationsFromModels
* generateMigrationsFromModels
*
*
* @param string $modelsPath
* @param string $modelsPath
* @return void
* @return void
*/
*/
public
function
generateMigrationsFromModels
(
$modelsPath
=
null
)
public
function
generateMigrationsFromModels
(
$modelsPath
=
null
)
...
@@ -160,47 +160,47 @@ END;
...
@@ -160,47 +160,47 @@ END;
}
else
{
}
else
{
$models
=
Doctrine
::
getLoadedModels
();
$models
=
Doctrine
::
getLoadedModels
();
}
}
$foreignKeys
=
array
();
$foreignKeys
=
array
();
foreach
(
$models
as
$model
)
{
foreach
(
$models
as
$model
)
{
$export
=
Doctrine
::
getTable
(
$model
)
->
getExportableFormat
();
$export
=
Doctrine
::
getTable
(
$model
)
->
getExportableFormat
();
$foreignKeys
[
$export
[
'tableName'
]]
=
$export
[
'options'
][
'foreignKeys'
];
$foreignKeys
[
$export
[
'tableName'
]]
=
$export
[
'options'
][
'foreignKeys'
];
$up
=
$this
->
buildCreateTable
(
$export
);
$up
=
$this
->
buildCreateTable
(
$export
);
$down
=
$this
->
buildDropTable
(
$export
);
$down
=
$this
->
buildDropTable
(
$export
);
$className
=
'Add'
.
Doctrine
::
classify
(
$export
[
'tableName'
]);
$className
=
'Add'
.
Doctrine
::
classify
(
$export
[
'tableName'
]);
$this
->
generateMigrationClass
(
$className
,
array
(),
$up
,
$down
);
$this
->
generateMigrationClass
(
$className
,
array
(),
$up
,
$down
);
}
}
$className
=
'ApplyForeignKeyConstraints'
;
$className
=
'ApplyForeignKeyConstraints'
;
$up
=
''
;
$up
=
''
;
$down
=
''
;
$down
=
''
;
foreach
(
$foreignKeys
as
$tableName
=>
$definitions
)
{
foreach
(
$foreignKeys
as
$tableName
=>
$definitions
)
{
$tableForeignKeyNames
[
$tableName
]
=
array
();
$tableForeignKeyNames
[
$tableName
]
=
array
();
foreach
(
$definitions
as
$definition
)
{
foreach
(
$definitions
as
$definition
)
{
$definition
[
'name'
]
=
$tableName
.
'_'
.
$definition
[
'foreignTable'
]
.
'_'
.
$definition
[
'local'
]
.
'_'
.
$definition
[
'foreign'
];
$definition
[
'name'
]
=
$tableName
.
'_'
.
$definition
[
'foreignTable'
]
.
'_'
.
$definition
[
'local'
]
.
'_'
.
$definition
[
'foreign'
];
$up
.=
$this
->
buildCreateForeignKey
(
$tableName
,
$definition
);
$up
.=
$this
->
buildCreateForeignKey
(
$tableName
,
$definition
);
$down
.=
$this
->
buildDropForeignKey
(
$tableName
,
$definition
);
$down
.=
$this
->
buildDropForeignKey
(
$tableName
,
$definition
);
}
}
}
}
$this
->
generateMigrationClass
(
$className
,
array
(),
$up
,
$down
);
$this
->
generateMigrationClass
(
$className
,
array
(),
$up
,
$down
);
return
true
;
return
true
;
}
}
/**
/**
* buildCreateForeignKey
* buildCreateForeignKey
*
*
* @param string $tableName
* @param string $tableName
* @param string $definition
* @param string $definition
* @return void
* @return void
*/
*/
public
function
buildCreateForeignKey
(
$tableName
,
$definition
)
public
function
buildCreateForeignKey
(
$tableName
,
$definition
)
...
@@ -211,8 +211,8 @@ END;
...
@@ -211,8 +211,8 @@ END;
/**
/**
* buildDropForeignKey
* buildDropForeignKey
*
*
* @param string $tableName
* @param string $tableName
* @param string $definition
* @param string $definition
* @return void
* @return void
*/
*/
public
function
buildDropForeignKey
(
$tableName
,
$definition
)
public
function
buildDropForeignKey
(
$tableName
,
$definition
)
...
@@ -223,26 +223,26 @@ END;
...
@@ -223,26 +223,26 @@ END;
/**
/**
* buildCreateTable
* buildCreateTable
*
*
* @param string $tableData
* @param string $tableData
* @return void
* @return void
*/
*/
public
function
buildCreateTable
(
$tableData
)
public
function
buildCreateTable
(
$tableData
)
{
{
$code
=
"
\t\t\$
this->createTable('"
.
$tableData
[
'tableName'
]
.
"', "
;
$code
=
"
\t\t\$
this->createTable('"
.
$tableData
[
'tableName'
]
.
"', "
;
$code
.=
var_export
(
$tableData
[
'columns'
],
true
)
.
", "
;
$code
.=
var_export
(
$tableData
[
'columns'
],
true
)
.
", "
;
$code
.=
var_export
(
array
(
'indexes'
=>
$tableData
[
'options'
][
'indexes'
],
'primary'
=>
$tableData
[
'options'
][
'primary'
]),
true
);
$code
.=
var_export
(
array
(
'indexes'
=>
$tableData
[
'options'
][
'indexes'
],
'primary'
=>
$tableData
[
'options'
][
'primary'
]),
true
);
$code
.=
");"
;
$code
.=
");"
;
return
$code
;
return
$code
;
}
}
/**
/**
* buildDropTable
* buildDropTable
*
*
* @param string $tableData
* @param string $tableData
* @return string
* @return string
*/
*/
public
function
buildDropTable
(
$tableData
)
public
function
buildDropTable
(
$tableData
)
...
@@ -263,16 +263,16 @@ END;
...
@@ -263,16 +263,16 @@ END;
if
(
!
$this
->
getMigrationsPath
())
{
if
(
!
$this
->
getMigrationsPath
())
{
throw
new
Doctrine_Migration_Exception
(
'You must specify the path to your migrations.'
);
throw
new
Doctrine_Migration_Exception
(
'You must specify the path to your migrations.'
);
}
}
$migration
=
new
Doctrine_Migration
(
$this
->
getMigrationsPath
());
$migration
=
new
Doctrine_Migration
(
$this
->
getMigrationsPath
());
$next
=
(
string
)
$migration
->
getNextVersion
();
$next
=
(
string
)
$migration
->
getNextVersion
();
$fileName
=
str_repeat
(
'0'
,
(
3
-
strlen
(
$next
)))
.
$next
.
'_'
.
Doctrine
::
tableize
(
$className
)
.
$this
->
_suffix
;
$fileName
=
str_repeat
(
'0'
,
(
3
-
strlen
(
$next
)))
.
$next
.
'_'
.
Doctrine
::
tableize
(
$className
)
.
$this
->
_suffix
;
$class
=
$this
->
buildMigrationClass
(
$className
,
$fileName
,
$options
,
$up
,
$down
);
$class
=
$this
->
buildMigrationClass
(
$className
,
$fileName
,
$options
,
$up
,
$down
);
$path
=
$this
->
getMigrationsPath
()
.
DIRECTORY_SEPARATOR
.
$fileName
;
$path
=
$this
->
getMigrationsPath
()
.
DIRECTORY_SEPARATOR
.
$fileName
;
file_put_contents
(
$path
,
$class
);
file_put_contents
(
$path
,
$class
);
}
}
}
}
...
@@ -285,15 +285,15 @@ END;
...
@@ -285,15 +285,15 @@ END;
public
function
buildMigrationClass
(
$className
,
$fileName
=
null
,
$options
=
array
(),
$up
=
null
,
$down
=
null
)
public
function
buildMigrationClass
(
$className
,
$fileName
=
null
,
$options
=
array
(),
$up
=
null
,
$down
=
null
)
{
{
$extends
=
isset
(
$options
[
'extends'
])
?
$options
[
'extends'
]
:
'Doctrine_Migration'
;
$extends
=
isset
(
$options
[
'extends'
])
?
$options
[
'extends'
]
:
'Doctrine_Migration'
;
$content
=
'<?php'
.
PHP_EOL
;
$content
=
'<?php'
.
PHP_EOL
;
$content
.=
sprintf
(
self
::
$_tpl
,
$className
,
$content
.=
sprintf
(
self
::
$_tpl
,
$className
,
$extends
,
$extends
,
$up
,
$up
,
$down
);
$down
);
return
$content
;
return
$content
;
}
}
}
}
\ No newline at end of file
lib/Doctrine/Builder/Record.php
View file @
e2d8a916
This diff is collapsed.
Click to expand it.
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