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(); }