5 * Contains \Drupal\Console\Command\Node\AccessRebuildCommand.
8 namespace Drupal\Console\Command\Node;
10 use Symfony\Component\Console\Input\InputOption;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Core\Command\Command;
14 use Drupal\Core\State\StateInterface;
17 * Class AccessRebuildCommand
19 * @package Drupal\Console\Command\Node
21 class AccessRebuildCommand extends Command
29 * AccessRebuildCommand constructor.
31 * @param StateInterface $state
33 public function __construct(StateInterface $state)
35 $this->state = $state;
36 parent::__construct();
42 protected function configure()
45 ->setName('node:access:rebuild')
46 ->setDescription($this->trans('commands.node.access.rebuild.description'))
50 InputOption::VALUE_NONE,
51 $this->trans('commands.node.access.rebuild.options.batch')
52 )->setAliases(['nar']);
58 protected function execute(InputInterface $input, OutputInterface $output)
60 $this->getIo()->newLine();
61 $this->getIo()->comment(
62 $this->trans('commands.node.access.rebuild.messages.rebuild')
65 $batch = $input->getOption('batch');
67 node_access_rebuild($batch);
68 } catch (\Exception $e) {
69 $this->getIo()->error($e->getMessage());
74 $needs_rebuild = $this->state->get('node.node_access_needs_rebuild') ? : false;
76 $this->getIo()->error(
77 $this->trans('commands.node.access.rebuild.messages.failed')
83 $this->getIo()->success(
84 $this->trans('commands.node.access.rebuild.messages.completed')