5 use Symfony\Component\Console\Input\InputOption;
6 use Symfony\Component\Console\Input\InputArgument;
19 foreach ($seeders as $seed) {
20 $types[] = $seed::getType();
23 $this->setName(
'database:seed')
24 ->setDescription(
elgg_echo(
'cli:database:seed:description'))
25 ->addOption(
'limit',
'l', InputOption::VALUE_OPTIONAL,
26 elgg_echo(
'cli:database:seed:option:limit')
28 ->addOption(
'image_folder',
null, InputOption::VALUE_OPTIONAL,
29 elgg_echo(
'cli:database:seed:option:image_folder')
31 ->addOption(
'type',
't', InputOption::VALUE_OPTIONAL,
32 elgg_echo(
'cli:database:seed:option:type', [implode(
'|', $types)])
34 ->addOption(
'create_since',
null, InputOption::VALUE_OPTIONAL,
35 elgg_echo(
'cli:database:seed:option:create_since'),
'now'
37 ->addOption(
'create_until',
null, InputOption::VALUE_OPTIONAL,
38 elgg_echo(
'cli:database:seed:option:create_until'),
'now'
40 ->addArgument(
'create', InputArgument::OPTIONAL,
41 elgg_echo(
'cli:database:seed:argument:create')
49 if (!class_exists(
'\Faker\Generator')) {
50 elgg_log(
elgg_echo(
'cli:database:seed:log:error:faker'), \Psr\Log\LogLevel::ERROR);
58 elgg_log(
elgg_echo(
'cli:database:seed:log:error:logged_in'), \Psr\Log\LogLevel::ERROR);
63 _elgg_services()->set(
'mailer',
new \Laminas\Mail\Transport\InMemory());
64 _elgg_services()->events->registerHandler(
'enqueue',
'notification',
'\Elgg\Values::getFalse', 99999);
67 'limit' => $this->
option(
'limit'),
68 'image_folder' => $this->
option(
'image_folder'),
69 'type' => $this->
option(
'type'),
70 'create_since' => $this->
option(
'create_since'),
71 'create_until' => $this->
option(
'create_until'),
72 'create' => (bool) $this->
argument(
'create'),
73 'interactive' => !(bool) $this->
option(
'no-interaction'),
74 'cli_command' => $this,
79 }
catch (\Exception $e) {
80 elgg_log($e->getMessage(), \Psr\Log\LogLevel::ERROR);
82 return $e->getCode() ?: 3;
option($name)
Returns option value.
argument($name)
Returns argument value.
Abstract command with some utility methods.
elgg-cli database:seed [–limit]
command()
{Command to be executed.This method method should return an integer code of the error (or 0 for succe...
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
_elgg_services()
Get the global service provider.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
elgg_is_logged_in()
Returns whether or not the user is currently logged in.