Skip to content

Instantly share code, notes, and snippets.

@heddn
Created September 14, 2016 19:02
Show Gist options
  • Save heddn/7a7bad21e703bc88e566ea781ef27ddc to your computer and use it in GitHub Desktop.
Save heddn/7a7bad21e703bc88e566ea781ef27ddc to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\paragraphs\Plugin\migrate\destination;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\Core\Entity\ContentEntityInterface;
/**
* @MigrateDestination(
* id = "entity:paragraph"
* )
*/
class Paragraph extends EntityContentBase {
/**
* {@inheritdoc}
*/
protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
$entity->save();
return [
'target_id' => $entity->id(),
'target_revision_id' => $entity->getRevisionId(),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids = parent::getIds();
$revision_key = $this->getKey('revision');
$ids[$revision_key]['type'] = 'string';
return $ids;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment