mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
fix sf3 deprecated helpers for console command
This commit is contained in:
parent
4182c53304
commit
56be317d1b
@ -22,11 +22,12 @@ namespace Chill\CustomFieldsBundle\Command;
|
|||||||
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
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\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
use Symfony\Component\Yaml\Parser;
|
use Symfony\Component\Yaml\Parser;
|
||||||
use Symfony\Component\Yaml\Exception\ParseException;
|
use Symfony\Component\Yaml\Exception\ParseException;
|
||||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
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)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$helper = $this->getHelperSet()->get('question');
|
||||||
|
|
||||||
$em = $this->getContainer()
|
$em = $this->getContainer()
|
||||||
->get('doctrine.orm.default_entity_manager');
|
->get('doctrine.orm.default_entity_manager');
|
||||||
|
|
||||||
@ -83,27 +90,32 @@ class CreateFieldsOnGroupCommand extends ContainerAwareCommand
|
|||||||
. ' Please create at least one.</error>');
|
. ' Please create at least one.</error>');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = $this->getHelperSet()->get('table');
|
$table = new Table($output);
|
||||||
$table->setHeaders(array_merge(array('id', 'entity'), $this->getContainer()
|
$table
|
||||||
->getParameter('chill_main.available_languages')))
|
->setHeaders(array_merge(
|
||||||
->setRows($this->_prepareRows($customFieldsGroups));
|
['id', 'entity'],
|
||||||
$table->render($output);
|
$this->getContainer()->getParameter('chill_main.available_languages')
|
||||||
|
))
|
||||||
|
->setRows($this->_prepareRows($customFieldsGroups))
|
||||||
|
->render()
|
||||||
|
;
|
||||||
|
|
||||||
$customFieldsGroup = $dialog->askAndValidate($output,
|
$question = new Question(
|
||||||
"Enter the customfieldGroup's id on which the custom fields "
|
"Enter the customfieldGroup's id on which the custom fields should be added: ");
|
||||||
. "should be added :",
|
$question->setNormalizer(
|
||||||
function($answer) use ($customFieldsGroups) {
|
function($answer) use ($customFieldsGroups) {
|
||||||
foreach ($customFieldsGroups as $customFieldsGroup) {
|
foreach ($customFieldsGroups as $customFieldsGroup) {
|
||||||
if ($answer == $customFieldsGroup->getId()) {
|
if ($answer == $customFieldsGroup->getId()) {
|
||||||
return $customFieldsGroup;
|
return $customFieldsGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RunTimeException('The id does not match an existing '
|
throw new \RunTimeException('The id does not match an existing '
|
||||||
. 'CustomFieldsGroup');
|
. 'CustomFieldsGroup');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
$customFieldsGroup = $helper->ask($input, $output, $question);
|
||||||
|
|
||||||
|
|
||||||
if ($input->getOption(self::ARG_DELETE)) {
|
if ($input->getOption(self::ARG_DELETE)) {
|
||||||
$this->deleteFieldsForCFGroup($customFieldsGroup);
|
$this->deleteFieldsForCFGroup($customFieldsGroup);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user