Elgg  Version 3.0
DatabaseUnseedCommand.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cli;
4 
9 
13  protected function configure() {
14  $this->setName('database:unseed')
15  ->setDescription('Removes seeded fake entities from the database');
16  }
17 
21  protected function command() {
22 
23  if (!class_exists('\Faker\Generator')) {
24  elgg_log('This is a developer tool currently intended for testing purposes only. Please refrain from using it.', 'ERROR');
25  return 1;
26  }
27 
28  set_time_limit(0);
29 
30  _elgg_services()->setValue('mailer', new \Zend\Mail\Transport\InMemory());
31 
32  try {
33  _elgg_services()->seeder->unseed();
34  } catch (\Exception $e) {
35  elgg_log($e->getMessage(), 'ERROR');
36  return $e->getCode() ? : 3;
37  }
38 
39  return 0;
40  }
41 }
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:786
Abstract command with some utility methods.
Definition: Command.php:12
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
Namespace for generating in-memory filesystems.
Definition: InMemory.php:14