Si vous constatez la perte de tickets, de commentaires ou de projets, veuillez consulter la page https://status.framasoft.org/incident/626.

Commit 56be317d authored by Tchama's avatar Tchama

fix sf3 deprecated helpers for console command

parent 4182c533
Pipeline #222337 failed with stages
......@@ -22,11 +22,12 @@ namespace Chill\CustomFieldsBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Exception\ParseException;
use Chill\CustomFieldsBundle\Entity\CustomField;
......@@ -68,9 +69,15 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
}
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getHelperSet()->get('dialog');
$helper = $this->getHelperSet()->get('question');
$em = $this->getContainer()
->get('doctrine.orm.default_entity_manager');
......@@ -83,27 +90,32 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
. ' Please create at least one.</error>');
}
$table = $this->getHelperSet()->get('table');
$table->setHeaders(array_merge(array('id', 'entity'), $this->getContainer()
->getParameter('chill_main.available_languages')))
->setRows($this->_prepareRows($customFieldsGroups));
$table->render($output);
$table = new Table($output);
$table
->setHeaders(array_merge(
['id', 'entity'],
$this->getContainer()->getParameter('chill_main.available_languages')
))
->setRows($this->_prepareRows($customFieldsGroups))
->render()
;
$customFieldsGroup = $dialog->askAndValidate($output,
"Enter the customfieldGroup's id on which the custom fields "
. "should be added :",
$question = new Question(
"Enter the customfieldGroup's id on which the custom fields should be added: ");
$question->setNormalizer(
function($answer) use ($customFieldsGroups) {
foreach ($customFieldsGroups as $customFieldsGroup) {
if ($answer == $customFieldsGroup->getId()) {
return $customFieldsGroup;
}
}
throw new \RunTimeException('The id does not match an existing '
. 'CustomFieldsGroup');
}
);
$customFieldsGroup = $helper->ask($input, $output, $question);
if ($input->getOption(self::ARG_DELETE)) {
$this->deleteFieldsForCFGroup($customFieldsGroup);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment