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
37ffee97
Commit
37ffee97
authored
Oct 15, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the tasks from the cli so they are not together.
parent
ef40c049
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
144 additions
and
70 deletions
+144
-70
Cli.php
lib/Doctrine/Cli.php
+10
-10
Task.php
lib/Doctrine/Task.php
+95
-21
CreateDb.php
lib/Doctrine/Task/CreateDb.php
+3
-3
CreateTables.php
lib/Doctrine/Task/CreateTables.php
+3
-3
DropDb.php
lib/Doctrine/Task/DropDb.php
+3
-3
DumpData.php
lib/Doctrine/Task/DumpData.php
+3
-3
GenerateMigration.php
lib/Doctrine/Task/GenerateMigration.php
+3
-3
GenerateModelsFromDb.php
lib/Doctrine/Task/GenerateModelsFromDb.php
+3
-3
GenerateModelsFromYaml.php
lib/Doctrine/Task/GenerateModelsFromYaml.php
+3
-3
GenerateSql.php
lib/Doctrine/Task/GenerateSql.php
+3
-3
GenerateYamlFromDb.php
lib/Doctrine/Task/GenerateYamlFromDb.php
+3
-3
GenerateYamlFromModels.php
lib/Doctrine/Task/GenerateYamlFromModels.php
+3
-3
LoadData.php
lib/Doctrine/Task/LoadData.php
+3
-3
LoadDummyData.php
lib/Doctrine/Task/LoadDummyData.php
+3
-3
Migrate.php
lib/Doctrine/Task/Migrate.php
+3
-3
No files found.
lib/Doctrine/Cli.php
View file @
37ffee97
...
...
@@ -20,7 +20,7 @@
*/
/**
* Doctrine_Cli
_Task
* Doctrine_Cli
*
* @package Doctrine
* @subpackage Cli
...
...
@@ -54,18 +54,18 @@ class Doctrine_Cli
$taskName
=
str_replace
(
'-'
,
'_'
,
$args
[
1
]);
unset
(
$args
[
1
]);
$taskClass
=
'Doctrine_
Cli_
Task_'
.
Doctrine
::
classify
(
$taskName
);
$taskClass
=
'Doctrine_Task_'
.
Doctrine
::
classify
(
$taskName
);
if
(
class_exists
(
$taskClass
))
{
$taskInstance
=
new
$taskClass
();
$taskInstance
->
taskName
=
str_replace
(
'_'
,
'-'
,
Doctrine
::
tableize
(
str_replace
(
'Doctrine_Cli_Task_'
,
''
,
$taskName
)));
$args
=
$this
->
prepareArgs
(
$taskInstance
,
$args
);
$taskInstance
->
validate
(
$args
);
$taskInstance
->
setArguments
(
$args
);
$taskInstance
->
execute
();
if
(
$taskInstance
->
validate
())
{
$taskInstance
->
execute
();
}
}
else
{
throw
new
Doctrine_Cli_Exception
(
'Cli task could not be found: '
.
$taskClass
);
}
...
...
@@ -119,7 +119,7 @@ class Doctrine_Cli
foreach
(
$tasks
as
$taskName
)
{
$className
=
'Doctrine_
Cli_
Task_'
.
$taskName
;
$className
=
'Doctrine_Task_'
.
$taskName
;
$taskInstance
=
new
$className
();
$taskInstance
->
taskName
=
str_replace
(
'_'
,
'-'
,
Doctrine
::
tableize
(
$taskName
));
...
...
@@ -164,10 +164,10 @@ class Doctrine_Cli
public
function
loadTasks
(
$directory
=
null
)
{
if
(
$directory
===
null
)
{
$directory
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'Cli'
.
DIRECTORY_SEPARATOR
.
'Task'
;
$directory
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'Task'
;
}
$parent
=
new
ReflectionClass
(
'Doctrine_
Cli_
Task'
);
$parent
=
new
ReflectionClass
(
'Doctrine_Task'
);
$tasks
=
array
();
...
...
@@ -180,7 +180,7 @@ class Doctrine_Cli
if
(
end
(
$e
)
===
'php'
&&
strpos
(
$file
->
getFileName
(),
'.inc'
)
===
false
)
{
require_once
(
$file
->
getPathName
());
$className
=
'Doctrine_
Cli_
Task_'
.
$e
[
0
];
$className
=
'Doctrine_Task_'
.
$e
[
0
];
$class
=
new
ReflectionClass
(
$className
);
if
(
$class
->
isSubClassOf
(
$parent
))
{
...
...
lib/Doctrine/
Cli/
Task.php
→
lib/Doctrine/Task.php
View file @
37ffee97
...
...
@@ -23,14 +23,14 @@
* Doctrine_Cli_Task
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
abstract
class
Doctrine_
Cli_
Task
abstract
class
Doctrine_Task
{
public
$taskName
=
null
,
$description
=
null
,
...
...
@@ -38,16 +38,39 @@ abstract class Doctrine_Cli_Task
$requiredArguments
=
array
(),
$optionalArguments
=
array
();
/**
* __construct
*
* @return void
*/
public
function
__construct
()
{
$this
->
taskName
=
str_replace
(
'_'
,
'-'
,
Doctrine
::
tableize
(
str_replace
(
'Doctrine_Task_'
,
''
,
get_class
(
$this
))));
}
/**
* execute
*
* Override with each task class
*
* @return void
* @author Jonathan H. Wage
*/
abstract
function
execute
();
public
function
validate
(
$args
)
/**
* validate
*
* Validates that all required fields are present
*
* @return void
*/
public
function
validate
()
{
$this
->
arguments
=
$args
;
$requiredArguments
=
$this
->
getRequiredArguments
();
foreach
(
$requiredArguments
as
$arg
)
{
if
(
!
isset
(
$
arg
s
[
$arg
]))
{
if
(
!
isset
(
$
this
->
argument
s
[
$arg
]))
{
throw
new
Doctrine_Cli_Exception
(
'Required arguments missing. The follow arguments are required: '
.
implode
(
', '
,
$requiredArguments
));
}
}
...
...
@@ -55,6 +78,25 @@ abstract class Doctrine_Cli_Task
return
true
;
}
/**
* addArgument
*
* @param string $name
* @param string $value
* @return void
*/
public
function
addArgument
(
$name
,
$value
)
{
$this
->
arguments
[
$name
]
=
$value
;
}
/**
* getArgument
*
* @param string $name
* @param string $default
* @return void
*/
public
function
getArgument
(
$name
,
$default
=
null
)
{
if
(
isset
(
$this
->
arguments
[
$name
]))
{
...
...
@@ -64,53 +106,85 @@ abstract class Doctrine_Cli_Task
}
}
/**
* getArguments
*
* @return void
*/
public
function
getArguments
()
{
return
$this
->
arguments
;
}
/**
* setArguments
*
* @param string $args
* @return void
*/
public
function
setArguments
(
$args
)
{
$this
->
arguments
=
$args
;
}
/**
* getTaskName
*
* @return void
*/
public
function
getTaskName
()
{
return
$this
->
taskName
;
}
/**
* getDescription
*
* @return void
*/
public
function
getDescription
()
{
return
$this
->
description
;
}
/**
* getRequiredArguments
*
* @return void
*/
public
function
getRequiredArguments
()
{
return
array_keys
(
$this
->
requiredArguments
);
}
/**
* getOptionalArguments
*
* @return void
*/
public
function
getOptionalArguments
()
{
return
array_keys
(
$this
->
optionalArguments
);
}
/**
* getRequiredArgumentsDescriptions
*
* @return void
*/
public
function
getRequiredArgumentsDescriptions
()
{
return
$this
->
requiredArguments
;
}
/**
* getOptionalArgumentsDescriptions
*
* @return void
* @author Jonathan H. Wage
*/
public
function
getOptionalArgumentsDescriptions
()
{
return
$this
->
optionalArguments
;
}
public
function
getSyntax
()
{
$syntax
=
'./cli '
.
$this
->
getTaskName
();
if
(
$required
=
$this
->
getRequiredArguments
())
{
$syntax
.=
' <'
.
implode
(
'> <'
,
$required
)
.
'>'
;
}
if
(
$optional
=
$this
->
getOptionalArguments
())
{
$syntax
.=
' <'
.
implode
(
'> <'
,
$optional
)
.
'>'
;
}
return
$syntax
;
}
}
\ No newline at end of file
lib/Doctrine/
Cli/
Task/CreateDb.php
→
lib/Doctrine/Task/CreateDb.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_BuildDb
* Doctrine_Task_BuildDb
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_CreateDb
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_CreateDb
extends
Doctrine
_Task
{
public
$description
=
'Create database for each of your connections'
,
$optionalArguments
=
array
(
'connection'
=>
'Optionally specify a single connection to create the database for.'
);
...
...
lib/Doctrine/
Cli/
Task/CreateTables.php
→
lib/Doctrine/Task/CreateTables.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_CreateTables
* Doctrine_Task_CreateTables
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_CreateTables
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_CreateTables
extends
Doctrine
_Task
{
public
$description
=
'Create tables for all existing database connections'
,
$requiredArguments
=
array
(
'models_path'
=>
'Specify path to your models directory.'
),
...
...
lib/Doctrine/
Cli/
Task/DropDb.php
→
lib/Doctrine/Task/DropDb.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_DropDb
* Doctrine_Task_DropDb
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_DropDb
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_DropDb
extends
Doctrine
_Task
{
public
$description
=
'Drop database for all existing connections'
,
$requiredArguments
=
array
(),
...
...
lib/Doctrine/
Cli/
Task/DumpData.php
→
lib/Doctrine/Task/DumpData.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_DumpData
* Doctrine_Task_DumpData
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_DumpData
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_DumpData
extends
Doctrine
_Task
{
public
$description
=
'Dump data to a yaml data fixture file.'
,
$requiredArguments
=
array
(
'data_fixtures_path'
=>
'Specify path to write the yaml data fixtures file to.'
,
...
...
lib/Doctrine/
Cli/
Task/GenerateMigration.php
→
lib/Doctrine/Task/GenerateMigration.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateMigration
* Doctrine_Task_GenerateMigration
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateMigration
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateMigration
extends
Doctrine
_Task
{
public
$description
=
'Generate new migration class definition'
,
$requiredArguments
=
array
(
'class_name'
=>
'Name of the migration class to generate'
,
...
...
lib/Doctrine/
Cli/
Task/GenerateModelsFromDb.php
→
lib/Doctrine/Task/GenerateModelsFromDb.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateModelsFromDb
* Doctrine_Task_GenerateModelsFromDb
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateModelsFromDb
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateModelsFromDb
extends
Doctrine
_Task
{
public
$description
=
'Generates your Doctrine_Record definitions from your existing database connections.'
,
$requiredArguments
=
array
(
'models_path'
=>
'Specify path to your Doctrine_Record definitions.'
),
...
...
lib/Doctrine/
Cli/
Task/GenerateModelsFromYaml.php
→
lib/Doctrine/Task/GenerateModelsFromYaml.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateModelsFromYaml
* Doctrine_Task_GenerateModelsFromYaml
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateModelsFromYaml
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateModelsFromYaml
extends
Doctrine
_Task
{
public
$description
=
'Generates your Doctrine_Record definitions from a Yaml schema file'
,
$requiredArguments
=
array
(
'yaml_schema_path'
=>
'Specify the complete directory path to your yaml schema files.'
,
...
...
lib/Doctrine/
Cli/
Task/GenerateSql.php
→
lib/Doctrine/Task/GenerateSql.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateSql
* Doctrine_Task_GenerateSql
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateSql
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateSql
extends
Doctrine
_Task
{
public
$description
=
'Generate sql for all existing database connections.'
,
$requiredArguments
=
array
(
'models_path'
=>
'Specify complete path to your Doctrine_Record definitions.'
,
...
...
lib/Doctrine/
Cli/
Task/GenerateYamlFromDb.php
→
lib/Doctrine/Task/GenerateYamlFromDb.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateYamlFromDb
* Doctrine_Task_GenerateYamlFromDb
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateYamlFromDb
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateYamlFromDb
extends
Doctrine
_Task
{
public
$description
=
'Generates a Yaml schema file from an existing database'
,
$requiredArguments
=
array
(
'yaml_schema_path'
=>
'Specify the path to your yaml schema files.'
),
...
...
lib/Doctrine/
Cli/
Task/GenerateYamlFromModels.php
→
lib/Doctrine/Task/GenerateYamlFromModels.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_GenerateYamlFromModels
* Doctrine_Task_GenerateYamlFromModels
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_GenerateYamlFromModels
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_GenerateYamlFromModels
extends
Doctrine
_Task
{
public
$description
=
'Generates a Yaml schema file from existing Doctrine_Record definitions'
,
$requiredArguments
=
array
(
'yaml_schema_path'
=>
'Specify the complete directory path to your yaml schema files.'
,
...
...
lib/Doctrine/
Cli/
Task/LoadData.php
→
lib/Doctrine/Task/LoadData.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_LoadData
* Doctrine_Task_LoadData
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_LoadData
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_LoadData
extends
Doctrine
_Task
{
public
$description
=
'Load data from a yaml data fixture file.'
,
$requiredArguments
=
array
(
'data_fixtures_path'
=>
'Specify the complete path to load the yaml data fixtures files from.'
,
...
...
lib/Doctrine/
Cli/
Task/LoadDummyData.php
→
lib/Doctrine/Task/LoadDummyData.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_LoadDummyData
* Doctrine_Task_LoadDummyData
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_LoadDummyData
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_LoadDummyData
extends
Doctrine
_Task
{
public
$description
=
'Load data from a yaml data fixture file.'
,
$requiredArguments
=
array
(
'models_path'
=>
'Specify path to your Doctrine_Record definitions.'
),
...
...
lib/Doctrine/
Cli/
Task/Migrate.php
→
lib/Doctrine/Task/Migrate.php
View file @
37ffee97
...
...
@@ -20,17 +20,17 @@
*/
/**
* Doctrine_
Cli_
Task_Migrate
* Doctrine_Task_Migrate
*
* @package Doctrine
* @subpackage
Cli
* @subpackage
Task
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 2761 $
* @author Jonathan H. Wage <jwage@mac.com>
*/
class
Doctrine_
Cli_Task_Migrate
extends
Doctrine_Cli
_Task
class
Doctrine_
Task_Migrate
extends
Doctrine
_Task
{
public
$description
=
'Migrate database to latest version or the specified version'
,
$requiredArguments
=
array
(),
...
...
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