是否可以在ContainerAwareCommand中设置Container参数,如$this->getContainer()->setParameter('host', $host);
?
因为代码如下:
class ServerCommand extends ContainerAwareCommand
{
protected function configure()
{
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
$question1 = new Question('Provide a hostname: ', 'localhost');
$host = $helper->ask($input, $output, $question1);
$this->getContainer()->setParameter('host', $host);
给我DependencyInjection \ Exception \ LogicException:
无法在冻结的ParameterBag上调用set()。