60 'create_since' =>
'now',
61 'create_until' =>
'now',
62 'interactive' =>
true,
63 'cli_command' =>
null,
75 $cli_command =
$options[
'cli_command'];
83 foreach ($seeds as $seed) {
87 if (!empty($seed_options[
'type']) && $seed_options[
'type'] !== $seed::getType()) {
92 $seed_options[
'limit'] = $seed_options[
'limit'] ?? $seed::getDefaultLimit();
93 if ($interactive && $cli_command instanceof
Command) {
94 $seed_options[
'limit'] = (int) $cli_command->ask($this->translator->translate(
'cli:database:seed:ask:limit', [$seed::getType()]), $seed_options[
'limit'],
false,
false);
97 if ($seed_options[
'limit'] < 1) {
103 $seeder =
new $seed($seed_options);
105 $progress_bar = $this->progress->start($seed, $seed_options[
'limit']);
107 $seeder->setProgressBar($progress_bar);
111 $this->progress->finish($progress_bar);
131 $seeds = $this->getSeederClasses();
134 $trash_enabled = $this->config->trash_enabled;
135 $this->config->trash_enabled =
false;
136 foreach ($seeds as $seed) {
143 $seeder =
new $seed();
145 $progress_bar = $this->progress->start($seed, $seeder->getCount());
147 $seeder->setProgressBar($progress_bar);
151 $this->progress->finish($progress_bar);
155 $this->config->trash_enabled = $trash_enabled;
167 $seeds = $this->events->triggerResults(
'seeds',
'database', [], []);
168 foreach ($seeds as $seed) {
169 if (!class_exists($seed)) {
170 elgg_log(
"Seeding class {$seed} not found", \Psr\Log\LogLevel::ERROR);
174 if (!is_subclass_of($seed, Seed::class)) {
175 elgg_log(
"Seeding class {$seed} does not extend " . Seed::class, \Psr\Log\LogLevel::ERROR);
Abstract command with some utility methods.
unseed(array $options=[])
Remove all seeded entities.
seed(array $options=[])
Load seed scripts.
__construct(protected EventsService $events, protected Progress $progress, protected Invoker $invoker, protected Translator $translator, protected Config $config)
Seeder constructor.
getSeederClasses()
Get the class names of all registered seeders (verified to work for seeding)
elgg_set_config(string $name, $value)
Set an Elgg configuration value.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
const ELGG_IGNORE_ACCESS
elgg_call() flags
const ELGG_SHOW_DISABLED_ENTITIES
const ELGG_DISABLE_SYSTEM_LOG
const ELGG_SHOW_DELETED_ENTITIES
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
$config
Advanced site settings, debugging section.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.