Esempio n. 1
0
 /**
  * Retrieve a single object by its value.
  *
  * @param      string $enumName the name of the enum class
  * @param      int $id the id of the constant
  * @param      string $pluginName the name of the plugin
  * @param      PropelPDO $con the connection to use
  * @return     DynamicEnum
  */
 public static function retrieveByPluginValue($enumName, $id, $pluginName, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(DynamicEnumPeer::ENUM_NAME, $enumName);
     $criteria->add(DynamicEnumPeer::ID, $id);
     $criteria->add(DynamicEnumPeer::PLUGIN_NAME, $pluginName);
     return DynamicEnumPeer::doSelectOne($criteria, $con);
 }
 /**
  * Retrieve a single id by its value name.
  *
  * @param      string $enumName the name of the enum class
  * @param      string $valueName the name of the constant value
  * @param      PropelPDO $con the connection to use
  * @return     int DynamicEnum id
  */
 public static function retrieveValueByEnumValueName($enumName, $valueName, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(DynamicEnumPeer::ENUM_NAME, $enumName);
     $criteria->add(DynamicEnumPeer::VALUE_NAME, $valueName);
     $dynamicEnum = DynamicEnumPeer::doSelectOne($criteria, $con);
     if ($dynamicEnum) {
         return $dynamicEnum->getId();
     }
     return null;
 }
 /**
  * Return single integer value that represents the event type
  * @param KalturaEvent $event
  * @return int
  */
 protected function getEventType(KalturaEvent $event)
 {
     $matches = null;
     if (!preg_match('/k(\\w+)Event/', get_class($event), $matches)) {
         return null;
     }
     $typeName = $matches[1];
     $constName = strtoupper(preg_replace('/(?!^)[[:upper:]]/', '_\\0', $typeName));
     if (defined("EventNotificationEventType::{$constName}")) {
         $type = constant("EventNotificationEventType::{$constName}");
         if ($type) {
             return $type;
         }
     }
     return DynamicEnumPeer::retrieveValueByEnumValueName('EventNotificationEventType', $constName);
 }
 public static function apiToCore($type, $value)
 {
     $split = explode(IKalturaEnumerator::PLUGIN_VALUE_DELIMITER, $value, 2);
     if (count($split) == 1) {
         return $value;
     }
     $typeMap = self::getApiMap($type);
     if ($typeMap && isset($typeMap[$value])) {
         return $typeMap[$value];
     }
     list($pluginName, $valueName) = $split;
     $dynamicEnum = DynamicEnumPeer::retrieveByPluginConstant($type, $valueName, $pluginName);
     if (!$dynamicEnum) {
         $dynamicEnum = new DynamicEnum();
         $dynamicEnum->setEnumName($type);
         $dynamicEnum->setValueName($valueName);
         $dynamicEnum->setPluginName($pluginName);
         $dynamicEnum->save();
     }
     self::reloadMaps();
     return $dynamicEnum->getId();
 }
Esempio n. 5
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(DynamicEnumPeer::DATABASE_NAME);
         $criteria->add(DynamicEnumPeer::ID, $pks, Criteria::IN);
         $objs = DynamicEnumPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 public static function apiToCore($type, $value)
 {
     if (is_null($value)) {
         return null;
     }
     $split = explode(IKalturaEnumerator::PLUGIN_VALUE_DELIMITER, $value);
     if (count($split) == 1) {
         if (!preg_match('/[\\w\\d]+/', $value)) {
             throw new kCoreException("Dynamic enum invalid format [{$value}] for type [{$type}]", kCoreException::INVALID_ENUM_FORMAT);
         }
         return $value;
     }
     if (!preg_match('/\\w[\\w\\d]+\\.[\\w\\d]+/', $value)) {
         throw new kCoreException("Dynamic enum invalid format [{$value}] for type [{$type}]", kCoreException::INVALID_ENUM_FORMAT);
     }
     $typeMap = self::getApiMap($type);
     if ($typeMap && isset($typeMap[$value])) {
         return $typeMap[$value];
     }
     list($pluginName, $valueName) = $split;
     $dynamicEnum = DynamicEnumPeer::retrieveByPluginConstant($type, $valueName, $pluginName);
     if (!$dynamicEnum) {
         if (!self::$createNew) {
             throw new kCoreException("Dynamic enum not found [{$value}] for type [{$type}]", kCoreException::ENUM_NOT_FOUND);
         }
         $dynamicEnum = new DynamicEnum();
         $dynamicEnum->setEnumName($type);
         $dynamicEnum->setValueName($valueName);
         $dynamicEnum->setPluginName($pluginName);
         $dynamicEnum->save();
     }
     self::reloadMaps();
     return $dynamicEnum->getId();
 }
 /**
  * Return single integer value that represents the event object type
  * @param KalturaEvent $event
  * @return int
  */
 protected function getEventObjectType(KalturaEvent $event)
 {
     if ($event instanceof kBatchJobStatusEvent) {
         return EventNotificationEventObjectType::BATCHJOB;
     }
     if (!method_exists($event, 'getObject')) {
         return null;
     }
     $object = $event->getObject();
     $constName = strtoupper(get_class($object));
     if (defined("EventNotificationEventObjectType::{$constName}")) {
         $type = constant("EventNotificationEventObjectType::{$constName}");
         if ($type) {
             return $type;
         }
     }
     return DynamicEnumPeer::retrieveValueByEnumValueName('EventNotificationEventObjectType', $constName);
 }
 public static function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     kuserPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     entryPeer::clearInstancePool();
     //	    kvotePeer::clearInstancePool();
     //	    commentPeer::clearInstancePool();
     //	    flagPeer::clearInstancePool();
     //	    favoritePeer::clearInstancePool();
     //	    KshowKuserPeer::clearInstancePool();
     //	    MailJobPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     ControlPanelCommandPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     //	    PriorityGroupPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     //	    blockedEmailPeer::clearInstancePool();
     //	    conversionPeer::clearInstancePool();
     //	    flickrTokenPeer::clearInstancePool();
     PuserKuserPeer::clearInstancePool();
     //	    PuserRolePeer::clearInstancePool();
     PartnerPeer::clearInstancePool();
     //	    WidgetLogPeer::clearInstancePool();
     //	    adminKuserPeer::clearInstancePool();
     //	    notificationPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     //	    widgetPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     //	    PartnerStatsPeer::clearInstancePool();
     //	    PartnerActivityPeer::clearInstancePool();
     ConversionProfilePeer::clearInstancePool();
     //	    ConversionParamsPeer::clearInstancePool();
     //	    KceInstallationErrorPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     accessControlPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     assetParamsPeer::clearInstancePool();
     assetParamsOutputPeer::clearInstancePool();
     assetPeer::clearInstancePool();
     conversionProfile2Peer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     //	    SystemUserPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     //	    EmailIngestionProfilePeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     //	    invalidSessionPeer::clearInstancePool();
     DynamicEnumPeer::clearInstancePool();
     UserLoginDataPeer::clearInstancePool();
     PermissionPeer::clearInstancePool();
     UserRolePeer::clearInstancePool();
     PermissionItemPeer::clearInstancePool();
     PermissionToPermissionItemPeer::clearInstancePool();
     KuserToUserRolePeer::clearInstancePool();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaMemoryCleaner');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->cleanMemory();
     }
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
Esempio n. 9
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = DynamicEnumPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setEnumName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setValueName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPluginName($arr[$keys[3]]);
     }
 }