Working with symfony2.3.4 and PHP5.6.3
I´m implementing a command of my own, well it actually does basically the same as doctrine:generate:entity only with some customization of mine.
I'm stuck trying to implement the constructor method in my class OwnEntityCommand.php which extends from GenerateDoctrineEntityCommand class which follows a line of upward inheritance until it reaches Command.php.
The constructor in that last class looks like this:
public function __contruct($name = null) {
$this->definition = new InputDefinition();
$this->ignoreValidationErrors = false;
$this->applicationDefinitionMerged = false;
$this->applicationDefinitionMergedWithArgs = false;
$this->aliases = array();
if(null !== $name){
$this->setName($name);
}
$this->configure();
if($this->name){
throw new \LogicException('The command name cannot be empty.');
}
}
and the one I need in mine is supposed to look like this:
public function __construct(Filesystem $filesystem, RegistryInterface $registry){
$this->filesystem = $filesystem;
$this->registry = $registry;
}
and the only attrs in my class being:
private $filesystem;
private $registry;
when I try to run the command it throws:
[InvalidArgumentException] Command "own:entity" is not defined.
do not know how to implement my own constructor without conflicting with the parent's(which I think is what's happening)
if need more data or code, just tell me
UPDATE:
protected function configure() {
$this
->setName('own:entity')
->setAliases(array('generate:own:entity'))
->setDescription('Generates a new Doctrine entity inside a bundle')
->addOption('entity', null, InputOption::VALUE_OPTIONAL, 'The entity class name to initialize (shortcut notation)', 'UserBundle:TestEntity')
->addOption('fields', null, InputOption::VALUE_REQUIRED, 'The fields to create with the new entity')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'Use the format for configuration files (php, xml, yml, or annotation)', 'annotation')
->addOption('with-repository', null, InputOption::VALUE_NONE, 'Whether to generate the entity repository or not');
}