Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / migrate_plus / src / Entity / MigrationGroup.php
1 <?php
2
3 namespace Drupal\migrate_plus\Entity;
4
5 use Drupal\Core\Config\Entity\ConfigEntityBase;
6
7 /**
8  * Defines the Migration Group entity.
9  *
10  * The migration group entity is used to group active migrations, as well as to
11  * store shared migration configuration.
12  *
13  * @ConfigEntityType(
14  *   id = "migration_group",
15  *   label = @Translation("Migration Group"),
16  *   module = "migrate_plus",
17  *   handlers = {
18  *   },
19  *   entity_keys = {
20  *     "id" = "id",
21  *     "label" = "label"
22  *   }
23  * )
24  */
25 class MigrationGroup extends ConfigEntityBase implements MigrationGroupInterface {
26
27   /**
28    * The migration group ID (machine name).
29    *
30    * @var string
31    */
32   protected $id;
33
34   /**
35    * The human-readable label for the migration group.
36    *
37    * @var string
38    */
39   protected $label;
40
41   /**
42    * {@inheritdoc}
43    */
44   public function delete() {
45     // Delete all migrations contained in this group.
46     $query = \Drupal::entityQuery('migration')
47       ->condition('migration_group', $this->id());
48     $names = $query->execute();
49
50     // Order the migrations according to their dependencies.
51     /** @var MigrationInterface[] $migrations */
52     $migrations = \Drupal::entityTypeManager()->getStorage('migration')->loadMultiple($names);
53
54     // Delete in reverse order, so dependencies are never violated.
55     $migrations = array_reverse($migrations);
56
57     foreach ($migrations as $migration) {
58       $migration->delete();
59     }
60
61     // Finally, delete the group itself.
62     parent::delete();
63   }
64
65   /**
66    * {@inheritdoc}
67    */
68   public function calculateDependencies() {
69     parent::calculateDependencies();
70     // Make sure we save any explicit module dependencies.
71     if ($provider = $this->get('module')) {
72       $this->addDependency('module', $provider);
73     }
74     return $this->dependencies;
75   }
76
77 }