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();
 }
 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();
 }
Example #3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      DynamicEnum $value A DynamicEnum object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(DynamicEnum $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('DynamicEnumPeer');
         }
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      DynamicEnum $value A DynamicEnum object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(DynamicEnum $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }