Version 1
[yaffs-website] / web / core / modules / system / src / Plugin / migrate / destination / EntityDateFormat.php
diff --git a/web/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php b/web/core/modules/system/src/Plugin/migrate/destination/EntityDateFormat.php
new file mode 100644 (file)
index 0000000..42ba166
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace Drupal\system\Plugin\migrate\destination;
+
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\migrate\Plugin\migrate\destination\EntityConfigBase;
+
+/**
+ * @MigrateDestination(
+ *   id = "entity:date_format"
+ * )
+ */
+class EntityDateFormat extends EntityConfigBase {
+
+  /**
+   * {@inheritdoc}
+   *
+   * @param \Drupal\Core\Datetime\DateFormatInterface $entity
+   *   The date entity.
+   */
+  protected function updateEntityProperty(EntityInterface $entity, array $parents, $value) {
+    if ($parents[0] == 'pattern') {
+      $entity->setPattern($value);
+    }
+    else {
+      parent::updateEntityProperty($entity, $parents, $value);
+    }
+  }
+
+}