public static function setMetadataSet(Cascade $target_cascade, Site $source_site, Site $target_site, Asset $source_asset, Asset $target_asset, $exception_thrown = true) { // get metadata set $source_ms = $source_asset->getMetadataSet(); $source_ms_path = u\StringUtility::removeSiteNameFromPath($source_ms->getPath()); $source_ms_site = $source_ms->getSiteName(); $target_ms_site = $source_ms_site; if ($exception_thrown) { try { $ms = $target_cascade->getAsset(MetadataSet::TYPE, $source_ms_path, $target_ms_site); $target_asset->setMetadataSet($ms); } catch (\Exception $e) { $msg = "The metadata set {$source_ms_path} does not exist in {$target_ms_site}. "; throw new e\CascadeInstancesErrorException(S_SPAN . $msg . E_SPAN . $e); } } else { $ms = $target_cascade->getMetadataSet($source_ms_path, $target_ms_site); if (isset($ms)) { $target_asset->setMetadataSet($ms); } } // set metadata if (isset($ms)) { try { $m = $source_asset->getMetadata(); $target_asset->setMetadata($m); $source_metadata = $source_asset->getMetadata(); $target_metadata = $target_asset->getMetadata(); $target_metadata->setAuthor($source_metadata->getAuthor())->setDisplayName($source_metadata->getDisplayName())->setEndDate($source_metadata->getEndDate())->setKeywords($source_metadata->getKeywords())->setMetaDescription($source_metadata->getMetaDescription())->setReviewDate($source_metadata->getReviewDate())->setStartDate($source_metadata->getStartDate())->setSummary($source_metadata->getSummary())->setTeaser($source_metadata->getTeaser())->setTitle($source_metadata->getTitle()); $fields = $source_metadata->getDynamicFieldNames(); $count = count($fields); if ($count > 0) { foreach ($fields as $field) { $target_metadata->setDynamicField($field, $source_metadata->getDynamicFieldValues($field)); } } $target_asset->edit(); } catch (\Exception $e) { throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $source_asset->getPath() . E_SPAN); } } }