6 use Elgg\Traits\Loggable;
8 use Symfony\Component\Console\Helper\FormatterHelper;
9 use Symfony\Component\Console\Helper\QuestionHelper;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Question\Question;
13 use Symfony\Component\VarDumper\VarDumper;
18 abstract class BaseCommand extends \Symfony\Component\Console\Command\Command {
46 $helper = $this->getHelper(
'question');
48 $question = trim($question);
49 $question = rtrim($question,
':');
51 $question .=
" [{$default}]";
56 $q =
new Question($question,
$default);
60 $q->setHiddenFallback(
false);
68 $q->setMaxAttempts(2);
71 return $helper->ask($this->input, $this->output, $q);
82 VarDumper::dump(
$data);
94 $formatter =
new FormatterHelper();
97 case LogLevel::EMERGENCY:
98 case LogLevel::CRITICAL:
100 case LogLevel::ERROR:
104 case LogLevel::WARNING:
147 return $this->input->getOption(
$name);
158 return $this->input->getArgument(
$name);
170 if (empty($answer)) {
184 foreach ($registers as $prop => $values) {
185 if (!empty($values)) {
186 foreach ($values as $msg) {
187 $prop ==
'error' ? $this->
error($msg) : $this->
notice($msg);
if(! $user||! $user->canDelete()) $name
if(! $entity instanceof \ElggUser) $data
Adds interaction to a console command.
option($name)
Returns option value.
dump($data)
Dump a variable.
ask($question, $default=null, $hidden=false, $required=true)
Ask a question.
assertNotEmpty($answer)
Question validator for required user response.
write($messages, $level=LogLevel::INFO)
Write messages to output buffer.
dumpRegisters()
Dump and output system and error messages.
notice($message)
Print a notce.
error($message)
Print an error.
argument($name)
Returns argument value.
Exception thrown if an error which can only be found on runtime occurs.
_elgg_services()
Get the global service provider.