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
c5e1a15f
Commit
c5e1a15f
authored
Oct 11, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few tweaks to arguments and how they are handled.
parent
26945749
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
41 deletions
+28
-41
Cli.php
lib/Doctrine/Cli.php
+28
-6
Task.php
lib/Doctrine/Cli/Task.php
+0
-35
No files found.
lib/Doctrine/Cli.php
View file @
c5e1a15f
...
...
@@ -60,8 +60,7 @@ class Doctrine_Cli
$taskInstance
=
new
$taskClass
();
$taskInstance
->
taskName
=
str_replace
(
'_'
,
'-'
,
Doctrine
::
tableize
(
str_replace
(
'Doctrine_Cli_Task_'
,
''
,
$taskName
)));
$args
=
$taskInstance
->
prepareArgs
(
$args
);
$args
=
$this
->
prepareArgs
(
$args
);
$args
=
$this
->
prepareArgs
(
$taskInstance
,
$args
);
$taskInstance
->
validate
(
$args
);
...
...
@@ -72,17 +71,40 @@ class Doctrine_Cli
}
}
protected
function
prepareArgs
(
$args
)
protected
function
prepareArgs
(
$
taskInstance
,
$
args
)
{
$args
=
array_values
(
$args
);
$prepared
=
array
();
$requiredArguments
=
$taskInstance
->
getRequiredArguments
();
foreach
(
$requiredArguments
as
$key
=>
$arg
)
{
$prepared
[
$arg
]
=
null
;
}
$optionalArguments
=
$taskInstance
->
getOptionalArguments
();
foreach
(
$optionalArguments
as
$key
=>
$arg
)
{
$prepared
[
$arg
]
=
null
;
}
if
(
is_array
(
$this
->
config
)
&&
!
empty
(
$this
->
config
))
{
foreach
(
$this
->
config
as
$key
=>
$value
)
{
if
(
array_key_exists
(
$key
,
$
args
))
{
$
args
[
$key
]
=
$value
;
if
(
array_key_exists
(
$key
,
$
prepared
))
{
$
prepared
[
$key
]
=
$value
;
}
}
}
return
$args
;
$copy
=
$args
;
foreach
(
$prepared
as
$key
=>
$value
)
{
if
(
!
$value
&&
!
empty
(
$copy
))
{
$prepared
[
$key
]
=
$copy
[
0
];
unset
(
$copy
[
0
]);
$copy
=
array_values
(
$copy
);
}
}
return
$prepared
;
}
public
function
printTasks
()
...
...
lib/Doctrine/Cli/Task.php
View file @
c5e1a15f
...
...
@@ -55,41 +55,6 @@ abstract class Doctrine_Cli_Task
return
true
;
}
public
function
prepareArgs
(
$args
)
{
$args
=
array_values
(
$args
);
$prepared
=
array
();
$requiredArguments
=
$this
->
getRequiredArguments
();
$count
=
0
;
foreach
(
$requiredArguments
as
$key
=>
$arg
)
{
if
(
isset
(
$args
[
$count
]))
{
$prepared
[
$arg
]
=
$args
[
$count
];
}
else
{
$prepared
[
$arg
]
=
null
;
}
$count
++
;
}
$optionalArguments
=
$this
->
getOptionalArguments
();
foreach
(
$optionalArguments
as
$key
=>
$arg
)
{
if
(
isset
(
$args
[
$count
]))
{
$prepared
[
$arg
]
=
$args
[
$count
];
}
else
{
$prepared
[
$arg
]
=
null
;
}
$count
++
;
}
$this
->
arguments
=
$prepared
;
return
$prepared
;
}
public
function
getArgument
(
$name
)
{
return
$this
->
arguments
[
$name
];
...
...
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