本文整理汇总了PHP中kCurrentContext::initPartnerByAssetId方法的典型用法代码示例。如果您正苦于以下问题:PHP kCurrentContext::initPartnerByAssetId方法的具体用法?PHP kCurrentContext::initPartnerByAssetId怎么用?PHP kCurrentContext::initPartnerByAssetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kCurrentContext
的用法示例。
在下文中一共展示了kCurrentContext::initPartnerByAssetId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serveAction
/**
* Serves attachment by its id
*
* @action serve
* @param string $attachmentAssetId
* @return file
*
* @throws KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND
*/
public function serveAction($attachmentAssetId)
{
$attachmentAsset = null;
if (!kCurrentContext::$ks) {
$attachmentAsset = kCurrentContext::initPartnerByAssetId($attachmentAssetId);
if (!$attachmentAsset || $attachmentAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND, $attachmentAssetId);
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
} else {
$attachmentAsset = assetPeer::retrieveById($attachmentAssetId);
}
if (!$attachmentAsset || !$attachmentAsset instanceof AttachmentAsset) {
throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND, $attachmentAssetId);
}
$entry = entryPeer::retrieveByPK($attachmentAsset->getEntryId());
if (!$entry) {
//we will throw attachment asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaAttachmentErrors::ATTACHMENT_ASSET_ID_NOT_FOUND, $attachmentAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, accessControlContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload();
$ext = $attachmentAsset->getFileExt();
if (is_null($ext)) {
$ext = 'txt';
}
$fileName = $attachmentAsset->getFilename();
if (!$fileName) {
$fileName = $attachmentAsset->getEntryId() . "_" . $attachmentAsset->getId() . ".{$ext}";
}
return $this->serveAsset($attachmentAsset, $fileName);
}
示例2: validateForDownload
/**
* @param string $captionAssetId
* @throws KalturaAPIException
* @return CaptionAsset
*/
protected function validateForDownload($captionAssetId)
{
$captionAsset = null;
if (!kCurrentContext::$ks) {
$captionAsset = kCurrentContext::initPartnerByAssetId($captionAssetId);
if (!$captionAsset || $captionAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
kEntitlementUtils::initEntitlementEnforcement();
} else {
$captionAsset = assetPeer::retrieveById($captionAssetId);
}
if (!$captionAsset || !$captionAsset instanceof CaptionAsset) {
throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId);
}
if (kCurrentContext::$ks_object && kCurrentContext::$ks_object->verifyPrivileges(CaptionPlugin::KS_PRIVILEGE_CAPTION, $captionAsset->getEntryId())) {
return $captionAsset;
}
$entry = entryPeer::retrieveByPK($captionAsset->getEntryId());
if (!$entry) {
//we will throw caption asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, ContextType::DOWNLOAD);
$securyEntryHelper->validateForDownload();
return $captionAsset;
}
示例3: serveAction
/**
* Serves thumbnail by its id
*
* @action serve
* @param string $thumbAssetId
* @param int $version
* @return file
*
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
*/
public function serveAction($thumbAssetId, $version = null)
{
if (!kCurrentContext::$ks) {
$thumbAsset = kCurrentContext::initPartnerByAssetId($thumbAssetId);
if (!$thumbAsset || $thumbAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
// enforce entitlement
kEntitlementUtils::initEntitlementEnforcement();
} else {
$thumbAsset = assetPeer::retrieveById($thumbAssetId);
}
if (!$thumbAsset || !$thumbAsset instanceof thumbAsset) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$entry = entryPeer::retrieveByPK($thumbAsset->getEntryId());
if (!$entry) {
//we will throw thumb asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, accessControlContextType::THUMBNAIL);
$securyEntryHelper->validateAccessControl();
$ext = $thumbAsset->getFileExt();
if (is_null($ext)) {
$ext = 'jpg';
}
$fileName = $thumbAsset->getEntryId() . "_" . $thumbAsset->getId() . ".{$ext}";
return $this->serveAsset($thumbAsset, $fileName, $version);
}
示例4: getFlavorAssetObject
private function getFlavorAssetObject($flavorAssetId)
{
try {
if (!kCurrentContext::$ks) {
$flavorAsset = kCurrentContext::initPartnerByAssetId($flavorAssetId);
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
kEntitlementUtils::initEntitlementEnforcement();
} else {
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
}
if (!$flavorAsset || $flavorAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaWidevineLicenseProxyException(KalturaWidevineErrorCodes::FLAVOR_ASSET_ID_NOT_FOUND);
}
return $flavorAsset;
} catch (PropelException $e) {
throw new KalturaWidevineLicenseProxyException(KalturaWidevineErrorCodes::FLAVOR_ASSET_ID_NOT_FOUND);
}
}
示例5: serveAction
/**
* Serves thumbnail by its id
*
* @action serve
* @param string $thumbAssetId
* @param int $version
* @param KalturaThumbParams $thumbParams
* @param KalturaThumbnailServeOptions $options
* @return file
*
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
*/
public function serveAction($thumbAssetId, $version = null, KalturaThumbParams $thumbParams = null, KalturaThumbnailServeOptions $options = null)
{
if (!kCurrentContext::$ks) {
$thumbAsset = kCurrentContext::initPartnerByAssetId($thumbAssetId);
if (!$thumbAsset || $thumbAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
kEntitlementUtils::initEntitlementEnforcement();
} else {
$thumbAsset = assetPeer::retrieveById($thumbAssetId);
}
if (!$thumbAsset || !$thumbAsset instanceof thumbAsset) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$entry = entryPeer::retrieveByPK($thumbAsset->getEntryId());
if (!$entry) {
//we will throw thumb asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, ContextType::THUMBNAIL);
$securyEntryHelper->validateAccessControl();
$ext = $thumbAsset->getFileExt();
if (is_null($ext)) {
$ext = 'jpg';
}
$fileName = $thumbAsset->getEntryId() . "_" . $thumbAsset->getId() . ".{$ext}";
if (!$thumbParams) {
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
return $this->serveAsset($thumbAsset, $fileName, $version);
}
$thumbParams->validate();
$syncKey = $thumbAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $version);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
/* @var $fileSync FileSync */
if (!$local) {
if (!in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
header("Location: {$remoteUrl}");
die;
}
$filePath = $fileSync->getFullPath();
$thumbVersion = $thumbAsset->getId() . '_' . $version;
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $thumbVersion, $thumbParams->width, $thumbParams->height, $thumbParams->cropType, $thumbParams->backgroundColor, null, $thumbParams->quality, $thumbParams->cropX, $thumbParams->cropY, $thumbParams->cropWidth, $thumbParams->cropHeight, -1, 0, -1, $filePath, $thumbParams->density, $thumbParams->stripProfiles, null);
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
$mimeType = kFile::mimeType($tempThumbPath);
return $this->dumpFile($tempThumbPath, $mimeType);
}