Elgg  Version 2.3
Seeder.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Database;
4 
10 
18 class Seeder {
19 
20  private $seeds = [
24  ];
25 
29  protected $hooks;
30 
37  $this->hooks = $hooks;
38  }
39 
45  public function seed() {
46  $ia = elgg_set_ignore_access(true);
47 
50 
51  foreach ($this->seeds as $seed) {
52  if (!class_exists($seed)) {
53  continue;
54  }
55  $seed = new $seed();
56  if (!is_subclass_of($seed, Seed::class)) {
57  continue;
58  }
59 
60  $seed->seed();
61  }
62 
64 
66  }
67 
72  public function unseed() {
73 
74  $ia = elgg_set_ignore_access(true);
75 
78 
79  foreach ($this->seeds as $seed) {
80  if (!class_exists($seed)) {
81  continue;
82  }
83  $seed = new $seed();
84  if (!is_subclass_of($seed, Seed::class)) {
85  continue;
86  }
87 
88  $seed->unseed();
89  }
90 
92 
94  }
95 }
__construct(PluginHooksService $hooks)
Seeder constructor.
Definition: Seeder.php:36
Seeder class.
Definition: Seeder.php:18
unseed()
Remove all seeded entities.
Definition: Seeder.php:72
elgg_set_ignore_access($ignore=true)
Set if Elgg&#39;s access system should be ignored.
Definition: access.php:43
seed()
Load seed scripts.
Definition: Seeder.php:45
access_get_show_hidden_status()
Return current status of showing disabled entities.
Definition: access.php:170
access_show_hidden_entities($show_hidden)
Show or hide disabled entities.
Definition: access.php:158
class
Definition: placeholder.php:21
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5