Skip to content

Loading…

Refactoring "hub" commands #91

Closed
willdurand opened this Issue · 2 comments

2 participants

@willdurand
Propel member

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
Propel 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.

@willdurand
Propel member

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

@willdurand willdurand closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.