Elgg  Version 6.1
PluginsDeactivateCommand.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cli;
4 
9 
14 
15  use PluginsHelper;
16 
20  protected function configure() {
21  $this->setName('plugins:deactivate')
22  ->setDescription(elgg_echo('cli:plugins:deactivate:description'))
23  ->addOption('force', 'f', InputOption::VALUE_NONE,
24  elgg_echo('cli:plugins:deactivate:option:force')
25  )
26  ->addArgument('plugins', InputArgument::REQUIRED | InputArgument::IS_ARRAY,
27  elgg_echo('cli:plugins:deactivate:argument:plugins')
28  );
29  }
30 
34  protected function command() {
35 
36  $ids = (array) $this->argument('plugins');
37  $force = (bool) $this->option('force');
38 
39  $helper = _elgg_services()->cli_progress;
40 
41  $progress = $helper->start(elgg_echo('cli:plugins:deactivate:progress:start'), count($ids));
42 
43  foreach ($ids as $id) {
44  try {
45  $this->deactivate($id, $force);
46  } catch (\Exception $ex) {
47  elgg_log($ex, LogLevel::ERROR);
48  }
49 
50  $progress->advance();
51  }
52 
53  $helper->finish($progress);
54 
55  return self::SUCCESS;
56  }
57 }
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:88
Abstract command with some utility methods.
Definition: Command.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
argument($name)
Returns argument value.
option($name)
Returns option value.
$id
Generic annotation delete action.
Definition: delete.php:6