本文整理汇总了PHP中assetPeer::setUseCriteriaFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP assetPeer::setUseCriteriaFilter方法的具体用法?PHP assetPeer::setUseCriteriaFilter怎么用?PHP assetPeer::setUseCriteriaFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assetPeer
的用法示例。
在下文中一共展示了assetPeer::setUseCriteriaFilter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveObject
/**
*
* @param int $objectType
* @param string $objectId
* @return ISyncableFile
*/
public static function retrieveObject($objectType, $objectId)
{
$object = null;
switch ($objectType) {
case FileSyncObjectType::ENTRY:
entryPeer::setUseCriteriaFilter(false);
$object = entryPeer::retrieveByPK($objectId);
entryPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::UICONF:
uiConfPeer::setUseCriteriaFilter(false);
$object = uiConfPeer::retrieveByPK($objectId);
uiConfPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::BATCHJOB:
BatchJobPeer::setUseCriteriaFilter(false);
$object = BatchJobPeer::retrieveByPK($objectId);
BatchJobPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::FLAVOR_ASSET:
assetPeer::setUseCriteriaFilter(false);
$object = assetPeer::retrieveById($objectId);
assetPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::SYNDICATION_FEED:
syndicationFeedPeer::setUseCriteriaFilter(false);
$object = syndicationFeedPeer::retrieveByPK($objectId);
syndicationFeedPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::CONVERSION_PROFILE:
conversionProfile2Peer::setUseCriteriaFilter(false);
$object = conversionProfile2Peer::retrieveByPK($objectId);
conversionProfile2Peer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::FILE_ASSET:
conversionProfile2Peer::setUseCriteriaFilter(false);
$object = FileAssetPeer::retrieveByPK($objectId);
conversionProfile2Peer::setUseCriteriaFilter(true);
break;
}
if ($object == null) {
$object = KalturaPluginManager::loadObject('ISyncableFile', $objectType, array('objectId' => $objectId));
}
if ($object == null) {
$error = __METHOD__ . " Cannot find object type [" . $objectType . "] with object_id [" . $objectId . "]";
KalturaLog::err($error);
throw new kFileSyncException($error);
}
return $object;
}
示例2: reload
/**
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
*
* This will only work if the object has been saved and has a valid primary key set.
*
* @param boolean $deep (optional) Whether to also de-associated any related objects.
* @param PropelPDO $con (optional) The PropelPDO connection to use.
* @return void
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
*/
public function reload($deep = false, PropelPDO $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("Cannot reload a deleted object.");
}
if ($this->isNew()) {
throw new PropelException("Cannot reload an unsaved object.");
}
if ($con === null) {
$con = Propel::getConnection(assetPeer::DATABASE_NAME, Propel::CONNECTION_READ);
}
// We don't need to alter the object instance pool; we're just modifying this instance
// already in the pool.
assetPeer::setUseCriteriaFilter(false);
$stmt = assetPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
assetPeer::setUseCriteriaFilter(true);
$row = $stmt->fetch(PDO::FETCH_NUM);
$stmt->closeCursor();
if (!$row) {
throw new PropelException('Cannot find matching row in the database to reload object values.');
}
$this->hydrate($row, 0, true);
// rehydrate
if ($deep) {
// also de-associate any related objects?
$this->aentry = null;
$this->aassetParams = null;
$this->collmediaInfos = null;
$this->lastmediaInfoCriteria = null;
$this->collassetParamsOutputs = null;
$this->lastassetParamsOutputCriteria = null;
}
// if (deep)
}
示例3: getObject
/**
* @return BaseObject
*/
public function getObject()
{
switch ($this->getObjectType()) {
case BatchJobObjectType::ENTRY:
entryPeer::setUseCriteriaFilter(false);
$object = entryPeer::retrieveByPK($this->getObjectId());
entryPeer::setUseCriteriaFilter(true);
return $object;
case BatchJobObjectType::ASSET:
assetPeer::setUseCriteriaFilter(false);
$object = assetPeer::retrieveById($this->getObjectId());
assetPeer::setUseCriteriaFilter(true);
return $object;
case BatchJobObjectType::CATEGORY:
categoryPeer::setUseCriteriaFilter(false);
$object = categoryPeer::retrieveByPK($this->getObjectId());
categoryPeer::setUseCriteriaFilter(true);
return $object;
case BatchJobObjectType::FILE_SYNC:
FileSyncPeer::setUseCriteriaFilter(false);
$object = FileSyncPeer::retrieveByPK($this->getObjectId());
FileSyncPeer::setUseCriteriaFilter(true);
return $object;
default:
// TODO implement IBatchable in relevant plugins
return KalturaPluginManager::loadObject('IBatchable', $this->getObjectId());
}
return $this->aRootJob;
}
示例4: restoreDeletedEntryAction
/**
* Restore deleted entry.
*
* @action restoreDeletedEntry
* @param string $entryId
* @return KalturaBaseEntry The restored entry
*/
public function restoreDeletedEntryAction($entryId)
{
$deletedEntry = entryPeer::retrieveByPKNoFilter($entryId);
if (!$deletedEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$fileSyncKeys = array();
foreach (self::$fileSyncKeysToRestore as $key) {
$fileSyncKeys[] = $deletedEntry->getSyncKey($key);
}
$c = new Criteria();
$c->add(assetPeer::ENTRY_ID, $entryId, Criteria::EQUAL);
assetPeer::setUseCriteriaFilter(false);
$deletedAssets = assetPeer::doSelect($c);
assetPeer::setUseCriteriaFilter(true);
foreach ($deletedAssets as $deletedAsset) {
array_push($fileSyncKeys, $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_CONVERT_LOG));
}
$fileSyncs = array();
FileSyncPeer::setUseCriteriaFilter(false);
foreach ($fileSyncKeys as $fileSyncKey) {
$fileSyncs = array_merge($fileSyncs, FileSyncPeer::retrieveAllByFileSyncKey($fileSyncKey));
}
FileSyncPeer::setUseCriteriaFilter(true);
if (!$this->validateEntryForRestoreDelete($deletedEntry, $fileSyncs, $deletedAssets)) {
throw new KalturaAPIException(KalturaAdminConsoleErrors::ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE, $entryId);
}
$this->restoreFileSyncs($fileSyncs);
//restore assets
foreach ($deletedAssets as $deletedAsset) {
$deletedAsset->setStatus(asset::ASSET_STATUS_READY);
$deletedAsset->save();
}
//restore entry
$deletedEntry->setStatusReady();
$deletedEntry->setThumbnail($deletedEntry->getFromCustomData("deleted_original_thumb"), true);
$deletedEntry->setData($deletedEntry->getFromCustomData("deleted_original_data"), true);
//data should be resotred even if it's NULL
$deletedEntry->save();
kEventsManager::flushEvents();
kMemoryManager::clearMemory();
$entry = KalturaEntryFactory::getInstanceByType($deletedEntry->getType(), true);
$entry->fromObject($deletedEntry, $this->getResponseProfile());
return $entry;
}
示例5: decideLiveProfile
public static function decideLiveProfile(LiveEntry $entry)
{
// find all live assets of the entry
$c = new Criteria();
$c->add(assetPeer::PARTNER_ID, $entry->getPartnerId());
$c->add(assetPeer::ENTRY_ID, $entry->getId());
$c->add(assetPeer::TYPE, assetType::LIVE);
// include deleted assets
assetPeer::setUseCriteriaFilter(false);
$liveAssets = assetPeer::doSelect($c);
assetPeer::setUseCriteriaFilter(true);
// build array of all assets with asset params id as key
$liveAssetsParams = array();
foreach ($liveAssets as $liveAsset) {
/* @var $liveAsset liveAsset */
$flavorParamsId = is_null($liveAsset->getFlavorParamsId()) ? $liveAsset->getId() : $liveAsset->getFlavorParamsId();
$liveAssetsParams[$flavorParamsId] = $liveAsset;
}
$flavorParamsConversionProfileArray = flavorParamsConversionProfilePeer::retrieveByConversionProfile($entry->getConversionProfileId());
$liveParamIdsArray = array();
foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) {
/* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
$liveParamIdsArray[] = $flavorParamsConversionProfile->getFlavorParamsId();
}
asort($liveParamIdsArray);
$liveParamIds = implode(",", $liveParamIdsArray);
if ($liveParamIds == $entry->getFlavorParamsIds()) {
return;
}
$streamBitrates = array();
$definedRecordingAnchor = false;
foreach ($flavorParamsConversionProfileArray as $flavorParamsConversionProfile) {
/* @var $flavorParamsConversionProfile flavorParamsConversionProfile */
$liveParams = $flavorParamsConversionProfile->getassetParams();
if ($liveParams instanceof liveParams) {
if ($flavorParamsConversionProfile->getOrigin() == assetParamsOrigin::INGEST) {
$streamBitrate = array('bitrate' => $liveParams->getVideoBitrate(), 'width' => $liveParams->getWidth(), 'height' => $liveParams->getHeight(), 'tags' => $liveParams->getTags());
$streamBitrates[] = $streamBitrate;
}
// check if asset already exists
if (isset($liveAssetsParams[$liveParams->getId()])) {
$liveAsset = $liveAssetsParams[$liveParams->getId()];
$liveAsset->setDeletedAt(null);
// remove the asset from the list, the left assets will be deleted later
unset($liveAssetsParams[$liveParams->getId()]);
} else {
// create a new asset
$liveAsset = new liveAsset();
$liveAsset->setType(assetType::LIVE);
$liveAsset->setPartnerId($entry->getPartnerId());
$liveAsset->setFlavorParamsId($liveParams->getId());
$liveAsset->setFromAssetParams($liveParams);
$liveAsset->setEntryId($entry->getId());
if ($entry->getRecordStatus() && !$definedRecordingAnchor) {
// We specifically add a flag that does NOT exist on the live asset, since we can't predict which
// live params the conversion profile is going to contain.
$liveAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR));
$definedRecordingAnchor = true;
}
}
// set the status according to the entry status
if ($entry->getStatus() == entryStatus::READY) {
$liveAsset->setStatus(asset::ASSET_STATUS_READY);
} else {
$liveAsset->setStatus(asset::ASSET_STATUS_IMPORTING);
}
$liveAsset->save();
}
}
// delete all left assets
foreach ($liveAssetsParams as $liveAsset) {
/* @var $liveAsset liveAsset */
$liveAsset->setDeletedAt(time());
$liveAsset->setStatus(asset::ASSET_STATUS_DELETED);
$liveAsset->save();
}
if (!count($streamBitrates)) {
$streamBitrate = array('bitrate' => 900, 'width' => 640, 'height' => 480);
$streamBitrates[] = $streamBitrate;
}
$entry->setStreamBitrates($streamBitrates);
$entry->save();
}
示例6: foreach
/* @var $deletedEntry entry */
echo 'changing status of entry ' . $deletedEntry->getId();
$deletedEntry->setStatusReady();
$deletedEntry->save();
entryPeer::clearInstancePool();
$entryFileSyncKey = $deletedEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$entryFileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($entryFileSyncKey);
foreach ($entryFileSyncs as $entryFileSync) {
$entryFileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
$entryFileSync->save();
}
//Restore assets
$assetCrit = new Criteria();
$assetCrit->add(assetPeer::ENTRY_ID, $deletedEntry->getId(), Criteria::EQUAL);
$assetCrit->add(assetPeer::STATUS, asset::ASSET_STATUS_DELETED, Criteria::EQUAL);
assetPeer::setUseCriteriaFilter(false);
$deletedAssets = assetPeer::doSelect($assetCrit);
foreach ($deletedAssets as $deletedAsset) {
/* @var $deletedAsset asset */
echo 'changing status of asset ' . $deletedAsset->getId();
$deletedAsset->setStatus(asset::ASSET_STATUS_READY);
$deletedAsset->save();
assetPeer::clearInstancePool();
$assetSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$assetfileSyncs = FileSyncPeer::retrieveAllByFileSyncKey($assetSyncKey);
foreach ($assetfileSyncs as $assetfileSync) {
if ($assetfileSync->getStatus() == FileSync::FILE_SYNC_STATUS_DELETED) {
$file_full_path = $assetfileSync->getFullPath();
if (file_exists($file_full_path)) {
echo 'LOG: Changing status of file_sync ' . $assetfileSync->getId() . ' to: ' . FileSync::FILE_SYNC_STATUS_READY . ".\n";
$assetfileSync->setStatus(FileSync::FILE_SYNC_STATUS_READY);
示例7: init
protected static function init()
{
kEventsManager::enableDeferredEvents(false);
MetadataProfilePeer::setUseCriteriaFilter(false);
MetadataPeer::setUseCriteriaFilter(false);
entryPeer::setUseCriteriaFilter(false);
uiConfPeer::setUseCriteriaFilter(false);
assetPeer::setUseCriteriaFilter(false);
PartnerPeer::setUseCriteriaFilter(false);
FileSyncPeer::setUseCriteriaFilter(false);
$options = getopt('hrl:p:o:b:e:', array('real-run', 'error-objects', 'old-versions', 'blocked-partners', 'files'));
if (isset($options['h'])) {
self::failWrongInputs();
}
if (isset($options['blocked-partners'])) {
self::$deleteDeletedPartnersFileSyncs = true;
}
if (isset($options['error-objects'])) {
self::$deleteErrorObjects = true;
}
if (isset($options['old-versions'])) {
self::$deleteOldVersions = true;
}
if (isset($options['files'])) {
self::$purgeDeletedFileSyncs = true;
}
if (isset($options['r']) || isset($options['real-run'])) {
self::$dryRun = false;
}
KalturaStatement::setDryRun(self::$dryRun);
$cacheFilePath = kConf::get('cache_root_path') . '/scripts/deleteOldContent.cache';
if (file_exists($cacheFilePath)) {
$cache = unserialize(file_get_contents($cacheFilePath));
if (isset($cache['oldVersionsStartUpdatedAt'])) {
self::$oldVersionsStartUpdatedAt = $cache['oldVersionsStartUpdatedAt'];
}
if (isset($cache['purgeStartUpdatedAt'])) {
self::$purgeStartUpdatedAt = $cache['purgeStartUpdatedAt'];
}
}
if (!self::$purgeStartUpdatedAt) {
$criteria = new Criteria();
$criteria->add(FileSyncPeer::UPDATED_AT, 0, Criteria::GREATER_THAN);
$criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
$criteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_DELETED);
$criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
$stmt = FileSyncPeer::doSelectStmt($criteria);
$mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (count($mins)) {
self::$purgeStartUpdatedAt = reset($mins);
}
}
if (is_null(self::$purgeStartUpdatedAt)) {
self::$purgeStartUpdatedAt = 0;
}
self::$purgeNextStartUpdatedAt = self::$purgeStartUpdatedAt;
$oldVersionsUpdatedAtPeriod = 30;
// days
if (isset($options['o'])) {
if (!is_numeric($options['o']) || $options['o'] < 0) {
self::failWrongInputs("Period of old versions to delete must be positive numeric of days");
}
$oldVersionsUpdatedAtPeriod = $options['o'];
}
foreach (self::$oldVersionsStartUpdatedAt as $objectType => $oldVersionsStartUpdatedAt) {
self::$oldVersionsEndUpdatedAt[$objectType] = $oldVersionsStartUpdatedAt + $oldVersionsUpdatedAtPeriod * 60 * 60 * 24;
}
// days
$purgeUpdatedAtPeriod = 30;
// days
if (isset($options['p'])) {
if (!is_numeric($options['p']) || $options['p'] < 0) {
self::failWrongInputs("Period of purge must be positive numeric of days");
}
$purgeUpdatedAtPeriod = $options['p'];
}
self::$purgeEndUpdatedAt = self::$purgeStartUpdatedAt + $purgeUpdatedAtPeriod * 60 * 60 * 24;
// days
$oldPartnersUpdatedAtPeriod = 24;
// months
if (isset($options['b'])) {
if (!is_numeric($options['b']) || $options['b'] < 0) {
self::failWrongInputs("Period of blocked partners to delete must be positive numeric of months");
}
$oldPartnersUpdatedAtPeriod = $options['b'];
}
self::$oldPartnersUpdatedAt = time() - $oldPartnersUpdatedAtPeriod * 60 * 60 * 24 * 30;
// months
$errObjectsUpdatedAtPeriod = 24;
// months
if (isset($options['e'])) {
if (!is_numeric($options['e']) || $options['e'] < 0) {
self::failWrongInputs("Period of error objects to delete must be positive numeric of months");
}
$errObjectsUpdatedAtPeriod = $options['e'];
}
self::$errObjectsUpdatedAt = time() - $errObjectsUpdatedAtPeriod * 60 * 60 * 24 * 30;
// months
if (isset($options['l'])) {
if (!is_numeric($options['l']) || $options['l'] < 0) {
//.........这里部分代码省略.........
示例8: objectDeleted
public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null)
{
/* @var $object FileSync */
$syncKey = kFileSyncUtils::getKeyForFileSync($object);
$entryId = null;
switch ($object->getObjectType()) {
case FileSyncObjectType::ENTRY:
$entryId = $object->getObjectId();
break;
case FileSyncObjectType::BATCHJOB:
BatchJobPeer::setUseCriteriaFilter(false);
$batchJob = BatchJobPeer::retrieveByPK($object->getObjectId());
if ($batchJob) {
$entryId = $batchJob->getEntryId();
}
BatchJobPeer::setUseCriteriaFilter(true);
break;
case FileSyncObjectType::ASSET:
assetPeer::setUseCriteriaFilter(false);
$asset = assetPeer::retrieveById($object->getId());
if ($asset) {
$entryId = $asset->getEntryId();
//the next piece of code checks whether the entry to which
//the deleted asset belongs to is a "replacement" entry
$entry = entryPeer::retrieveByPKNoFilter($entryId);
if (!$entry) {
KalturaLog::alert("No entry found by the ID of [{$entryId}]");
} else {
if ($entry->getReplacedEntryId()) {
KalturaLog::info("Will not handle event - deleted asset belongs to replacement entry");
return;
}
}
}
assetPeer::setUseCriteriaFilter(true);
break;
}
$storage = StorageProfilePeer::retrieveByPK($object->getDc());
kJobsManager::addStorageDeleteJob($raisedJob, $entryId, $storage, $object);
}
示例9: foreach
}
if ($key = $deletedEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC)) {
$entryFileSyncKeys[] = $key;
}
if ($key = $deletedEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_CONVERSION_LOG)) {
$entryFileSyncKeys[] = $key;
}
foreach ($entryFileSyncKeys as $entryFileSyncKey) {
restoreFileSyncByKey($entryFileSyncKey);
}
//Restore assets
$assetCrit = new Criteria();
$assetCrit->add(assetPeer::ENTRY_ID, $deletedEntry->getID(), Criteria::EQUAL);
assetPeer::setUseCriteriaFilter(false);
$deletedAssets = assetPeer::doSelect($assetCrit);
assetPeer::setUseCriteriaFilter(true);
foreach ($deletedAssets as $deletedAsset) {
/* @var $deletedAsset asset */
if ($deletedAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
echo 'changing status of asset to ready [' . $deletedAsset->getId() . ']';
$deletedAsset->setStatus(asset::ASSET_STATUS_READY);
$deletedAsset->save();
}
$assetSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
restoreFileSyncByKey($assetSyncKey);
$assetConvertLogSyncKey = $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_CONVERT_LOG);
restoreFileSyncByKey($assetConvertLogSyncKey);
}
kEventsManager::flushEvents();
kMemoryManager::clearMemory();
}
示例10: postInsert
/**
* Code to be run after inserting to database
* @param PropelPDO $con
*/
public function postInsert(PropelPDO $con = null)
{
assetPeer::setUseCriteriaFilter(false);
$this->reload();
assetPeer::setUseCriteriaFilter(true);
kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
if ($this->copiedFrom) {
kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
}
}