Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / draggableviews / src / Plugin / migrate / destination / DraggableViews.php
1 <?php
2
3 /**
4  * @file
5  * Contains destination plugin for Draggable Views database table.
6  */
7
8 namespace Drupal\draggableviews\Plugin\migrate\destination;
9
10 use Drupal\Core\Database\Database;
11 use Drupal\migrate\Entity\MigrationInterface;
12 use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
13 use Drupal\migrate\Row;
14
15 /**
16  * Defines destination plugin for Draggableviews.
17  *
18  * @MigrateDestination(
19  *   id = "draggableviews"
20  * )
21  */
22 class DraggableViews extends DestinationBase {
23
24   /**
25    * Constructs an entity destination plugin.
26    *
27    * @param array $configuration
28    *   A configuration array containing information about the plugin instance.
29    * @param string $plugin_id
30    *   The plugin_id for the plugin instance.
31    * @param mixed $plugin_definition
32    *   The plugin implementation definition.
33    * @param MigrationInterface $migration
34    *   The migration.
35    */
36   public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
37     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function import(Row $row, array $old_destination_id_values = []) {
44     $record = [
45       'view_name' => $row->getDestinationProperty('view_name'),
46       'view_display' => $row->getDestinationProperty('view_display'),
47       'args' => $row->getDestinationProperty('args'),
48       'entity_id' => $row->getDestinationProperty('entity_id'),
49       'weight' => $row->getDestinationProperty('weight'),
50       'parent' => $row->getDestinationProperty('parent'),
51     ];
52     $result = Database::getConnection()->insert('draggableviews_structure')->fields($record)->execute();
53     return array($result);
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function getIds() {
60     return [
61       'dvid' => [
62         'type' => 'integer',
63       ],
64     ];
65   }
66
67   /**
68    * {@inheritdoc}
69    */
70   public function fields(MigrationInterface $migration = NULL) {
71     return [
72       'dvid' => $this->t('The primarty identifier'),
73       'view_name' => $this->t('The view name.'),
74       'view_display' => $this->t('The view display.'),
75       'args' => $this->t('The arguments.'),
76       'entity_id' => $this->t('The entity id.'),
77       'weight' => $this->t('The order weight.'),
78       'parent' => $this->t('The parent entity id.'),
79     ];
80   }
81
82 }