public static function fromDbArray($arr, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaPlayReadyContentKeyArray();
     if ($arr == null) {
         return $newArr;
     }
     foreach ($arr as $obj) {
         $nObj = new KalturaPlayReadyContentKey();
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
Example #2
0
 /**
  * Get content key and key id for the given entry
  * 
  * @action getEntryContentKey
  * @param string $entryId 
  * @param bool $createIfMissing
  * @return KalturaPlayReadyContentKey $response
  * 
  */
 public function getEntryContentKeyAction($entryId, $createIfMissing = false)
 {
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $keySeed = $this->getPartnerKeySeed();
     $keyId = $this->getEntryKeyId($entry->getId());
     if (!$keyId && $createIfMissing) {
         $drmKey = new DrmKey();
         $drmKey->setPartnerId($entry->getPartnerId());
         $drmKey->setObjectId($entryId);
         $drmKey->setObjectType(DrmKeyObjectType::ENTRY);
         $drmKey->setProvider(PlayReadyPlugin::getPlayReadyProviderCoreValue());
         $keyId = kPlayReadyAESContentKeyGenerator::generatePlayReadyKeyId();
         $drmKey->setDrmKey($keyId);
         try {
             $drmKey->save();
             $entry->putInCustomData(PlayReadyPlugin::ENTRY_CUSTOM_DATA_PLAY_READY_KEY_ID, $keyId);
             $entry->save();
         } catch (PropelException $e) {
             if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) {
                 $keyId = $this->getEntryKeyId($entry->getId());
             } else {
                 throw $e;
                 // Rethrow the unfamiliar exception
             }
         }
     }
     if (!$keyId) {
         throw new KalturaAPIException(KalturaPlayReadyErrors::FAILED_TO_GET_ENTRY_KEY_ID, $entryId);
     }
     $contentKey = $this->createContentKeyObject($keySeed, $keyId);
     $response = new KalturaPlayReadyContentKey();
     $response->fromObject($contentKey, $this->getResponseProfile());
     return $response;
 }