/** * Clone an entry with optional attributes to apply to the clone * * @action clone * @param string $entryId Id of entry to clone * @param KalturaBaseEntry $updateEntry [optional] Attributes from these entry will be updated into the cloned entry * @return KalturaBaseEntry The cloned entry * @throws KalturaErrors::ENTRY_ID_NOT_FOUND */ function cloneAction($entryId) { // Reset criteria filters such that it will be entryPeer::setUseCriteriaFilter(false); categoryEntryPeer::setUseCriteriaFilter(false); // Get the entry $coreEntry = entryPeer::retrieveByPK($entryId); if (!$coreEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // Copy the entry into a new one based on the given partner data. $clonedEntry = myEntryUtils::copyEntry($coreEntry, $this->getPartner()); return $this->getEntry($clonedEntry->getId()); }
public static function copyEntriesByType(Partner $fromPartner, Partner $toPartner, $entryType, $dontCopyUsers = false) { KalturaLog::log("Copying entries from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "] with type [" . $entryType . "]"); entryPeer::setUseCriteriaFilter(false); $c = new Criteria(); $c->addAnd(entryPeer::PARTNER_ID, $fromPartner->getId()); $c->addAnd(entryPeer::TYPE, $entryType); $c->addAnd(entryPeer::STATUS, entryStatus::READY); $c->addDescendingOrderByColumn(entryPeer::CREATED_AT); $entries = entryPeer::doSelect($c); entryPeer::setUseCriteriaFilter(true); foreach ($entries as $entry) { myEntryUtils::copyEntry($entry, $toPartner, $dontCopyUsers); } }
/** * Clone an entry with optional attributes to apply to the clone * * @action clone * @param string $entryId Id of entry to clone * @param KalturaBaseEntryCloneOptionsArray $cloneOptions * @param KalturaBaseEntry $updateEntry [optional] Attributes from these entry will be updated into the cloned entry * @return KalturaBaseEntry The cloned entry * @throws KalturaErrors::ENTRY_ID_NOT_FOUND */ public function cloneAction($entryId, $cloneOptions = null) { // Reset criteria filters such that it will be entryPeer::setUseCriteriaFilter(false); categoryEntryPeer::setUseCriteriaFilter(false); // Get the entry $coreEntry = entryPeer::retrieveByPK($entryId); if (!$coreEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // $coreClonedOptionsArray = array(); // foreach ($cloneOptions as $item) // { // $coreClonedOptionsArray[] = $item->toObject(); // } $coreClonedOptionsArray = $cloneOptions->toObjectsArray(); // Copy the entry into a new one based on the given partner data. $clonedEntry = myEntryUtils::copyEntry($coreEntry, $this->getPartner(), $coreClonedOptionsArray); return $this->getEntry($clonedEntry->getId()); }