Refactoring "hub" commands #91

Closed
willdurand opened this Issue Dec 22, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@willdurand
Member

willdurand commented Dec 22, 2011

Some commands are using other commands but in a wrong way. We should refactor that part.

The existing code is more or less as below:

<?php

$cmd = new FooCommand();
$cmd->execute();

This is wrong and I don't know how it can work.. The execute() method is protected.

The right way is:

<?php

$in = new ArrayInput(array(
       'command'        => 'foo',
       '--verbose'      => $input->getOption('verbose'),
));

$cmd = $this->getApplication()->find('foo');
$cmd->run($in, $output);
@havvg

This comment has been minimized.

Show comment
Hide comment
@havvg

havvg Feb 18, 2012

Member

It works because each of these FooCommand is a AbstractPropelCommand. Since both objects are of the class defining the protected method and a spicy PHP bug (or feature?), they are allowed to call "their" protected method.

Member

havvg commented Feb 18, 2012

It works because each of these FooCommand is a AbstractPropelCommand. Since both objects are of the class defining the protected method and a spicy PHP bug (or feature?), they are allowed to call "their" protected method.

@willdurand

This comment has been minimized.

Show comment
Hide comment
@willdurand

willdurand Feb 18, 2012

Member

Maybe, I discovered the right way when I started to work on Propel2 commands..

Member

willdurand commented Feb 18, 2012

Maybe, I discovered the right way when I started to work on Propel2 commands..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment