private function MediaMigrationUuidOracle::setMediaProphecy in Media Migration 8
Saves a UUID prophecy if it doesn't exist.
Parameters
int $source_id: The source media entity's identifier.
Return value
string The UUID to save.
Throws
\Exception
1 call to MediaMigrationUuidOracle::setMediaProphecy()
- MediaMigrationUuidOracle::getMediaUuid in src/
MediaMigrationUuidOracle.php - Returns the UUID of a media entity based on its source ID.
File
- src/
MediaMigrationUuidOracle.php, line 102
Class
- MediaMigrationUuidOracle
- Media Migration's UUID oracle.
Namespace
Drupal\media_migrationCode
private function setMediaProphecy(int $source_id) {
$uuid = $this->uuidGenerator
->generate();
try {
$this->database
->insert(MediaMigration::MEDIA_UUID_PROPHECY_TABLE)
->fields([
MediaMigration::MEDIA_UUID_PROPHECY_SOURCEID_COL => $source_id,
MediaMigration::MEDIA_UUID_PROPHECY_UUID_COL => $uuid,
])
->execute();
return $uuid;
} catch (DatabaseExceptionWrapper $e) {
throw new \LogicException(sprintf('Cannot create prophecy for the media entity with source id %i', $source_id));
}
}