2013-03-05 68 views
0

我们有一个symfony 2控制台命令应用程序。在命令内部(扩展为\Symfony\Component\Console\Command\Command),我们调用另一个命令。再次调用应用程序 - >运行()

Code:

$this->getApplication()->run(new StringInput('cache:flush'), new NullOutput()); 

这是工作的罚款,直到更新到最新的Symfony版本

但现在我打的异常在下面的Symfony函数(\Symfony\Component\Console\Input\ArgvInput::parseArgument()

private function parseArgument($token) 
{ 
    $c = count($this->arguments); ## $c is 0 ! 

    // if input is expecting another argument, add it 
    if ($this->definition->hasArgument($c)) { 
     $arg = $this->definition->getArgument($c); 
     $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token; 

    // if last argument isArray(), append token to last argument 
    } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { 
     $arg = $this->definition->getArgument($c - 1); 
     $this->arguments[$arg->getName()][] = $token; 

    // unexpected argument 
    } else { 
     throw new \RuntimeException('Too many arguments.'); ### this exception is thrown 
    } 
} 

两个的命令(原始的一个dev:setup:run和我们所说的cache:flush)不需要pa rameters。

参考文献:https://github.com/netz98/n98-magerun/issues/90

回答

1

This commit导致Symfony2中不表现得像预期的,因为你可以看到the comments

但是,这个改变被恢复了,但只在Symfony2.2分支(这是一个错误,我猜)。您需要将您的控制台依赖项更新为某些2.2.x版本。
由于控制台组件中没有BC中断(只是一些really cool features),您可以更新到2.2.x版本

相关问题