当前位置: 首页>>代码示例>>PHP>>正文


PHP KalturaClient::getKalturaNullValue方法代码示例

本文整理汇总了PHP中KalturaClient::getKalturaNullValue方法的典型用法代码示例。如果您正苦于以下问题:PHP KalturaClient::getKalturaNullValue方法的具体用法?PHP KalturaClient::getKalturaNullValue怎么用?PHP KalturaClient::getKalturaNullValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KalturaClient的用法示例。


在下文中一共展示了KalturaClient::getKalturaNullValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseInputObject

function parseInputObject(SimpleXMLElement $input = null)
{
    global $inFile;
    if (is_null($input)) {
        return null;
    }
    if (isset($input['null']) && $input['null']) {
        return KalturaClient::getKalturaNullValue();
    }
    $type = 'string';
    if (isset($input['objectType'])) {
        $type = strval($input['objectType']);
    }
    $value = strval($input);
    $matches = null;
    if (preg_match('/\\{prompt:([^}]+)\\}/', $value, $matches)) {
        $userInput = askForUserParameter($matches[1]);
        $value = preg_replace('/\\{prompt:[^}]+\\}/', $userInput, $value);
    }
    if (preg_match('/\\{php:([^}]+)\\}/', $value, $matches)) {
        $value = eval($matches[1]);
    }
    if (preg_match('/\\{variable:([^}]+)\\}/', $value, $matches)) {
        global $variables;
        $value = isset($variables[$matches[1]]) ? $variables[$matches[1]] : null;
    }
    if (isset($input['path'])) {
        $path = $input['path'];
        if (!file_exists($path)) {
            $path = dirname($inFile) . '/' . $path;
            if (!file_exists($path)) {
                echo "File [{$path}] could not be found\n";
                exit(-1);
            }
        }
        $value = file_get_contents($path);
    }
    switch ($type) {
        case 'string':
            return $value;
        case 'int':
            return intval($value);
        case 'bool':
            return (bool) $value;
        case 'file':
            if (file_exists($value)) {
                return realpath($value);
            }
            $value = dirname($inFile) . '/' . $value;
            if (file_exists($value)) {
                return realpath($value);
            }
            echo "File [{$value}] could not be found\n";
            exit(-1);
        case 'array':
            return parseInputArray($input->item);
    }
    if (!class_exists($type)) {
        echo "Type [{$type}] could not be found\n";
        exit(-1);
    }
    $object = new $type();
    $properties = $input->children();
    foreach ($properties as $property) {
        /* @var $property SimpleXMLElement */
        $propertyName = $property->getName();
        $object->{$propertyName} = parseInputObject($property);
    }
    return $object;
}
开发者ID:GElkayam,项目名称:server,代码行数:70,代码来源:exec.php

示例2: fetchFile


//.........这里部分代码省略.........
             }
             if (isset($curlHeaderResponse->headers['content-length'])) {
                 $fileSize = $curlHeaderResponse->headers['content-length'];
             }
             $curlWrapper->close();
             if ($fileSize) {
                 clearstatcache();
                 $actualFileSize = kFile::fileSize($data->destFileLocalPath);
                 if ($actualFileSize >= $fileSize) {
                     return $this->moveFile($job, $data->destFileLocalPath, $fileSize);
                 } else {
                     $resumeOffset = $actualFileSize;
                 }
             }
         }
         $curlWrapper = new KCurlWrapper(self::$taskConfig->params);
         if (is_null($fileSize)) {
             // Read file size
             $curlHeaderResponse = $curlWrapper->getHeader($sourceUrl, true);
             if ($curlHeaderResponse && count($curlHeaderResponse->headers) && !$curlWrapper->getError() && isset($curlHeaderResponse->headers['content-length'])) {
                 $fileSize = $curlHeaderResponse->headers['content-length'];
             }
             //Close the curl used to fetch the header and create a new one.
             //When fetching headers we set curl options that than are not reset once header is fetched.
             //Not all servers support all the options so we need to remove them from our headers.
             $curlWrapper->close();
             $curlWrapper = new KCurlWrapper(self::$taskConfig->params);
         }
         if ($resumeOffset) {
             $curlWrapper->setResumeOffset($resumeOffset);
         } else {
             // creates a temp file path
             $destFile = $this->getTempFilePath($sourceUrl);
             KalturaLog::debug("destFile [{$destFile}]");
             $data->destFileLocalPath = $destFile;
             $data->fileSize = is_null($fileSize) ? -1 : $fileSize;
             $this->updateJob($job, "Downloading file, size: {$fileSize}", KalturaBatchJobStatus::PROCESSING, $data);
         }
         $res = $curlWrapper->exec($sourceUrl, $data->destFileLocalPath);
         KalturaLog::debug("Curl results: {$res}");
         if (!$res || $curlWrapper->getError()) {
             $errNumber = $curlWrapper->getErrorNumber();
             if ($errNumber != CURLE_OPERATION_TIMEOUTED) {
                 $this->closeJob($job, KalturaBatchJobErrorTypes::CURL, $errNumber, "Error: " . $curlWrapper->getError(), KalturaBatchJobStatus::RETRY);
                 $curlWrapper->close();
                 return $job;
             } else {
                 clearstatcache();
                 $actualFileSize = kFile::fileSize($data->destFileLocalPath);
                 if ($actualFileSize == $resumeOffset) {
                     $this->closeJob($job, KalturaBatchJobErrorTypes::CURL, $errNumber, "No new information. Error: " . $curlWrapper->getError(), KalturaBatchJobStatus::RETRY);
                     $curlWrapper->close();
                     return $job;
                 }
                 if (!$fileSize) {
                     $this->closeJob($job, KalturaBatchJobErrorTypes::CURL, $errNumber, "Received timeout, but no filesize available. Completed size [{$actualFileSize}]" . $curlWrapper->getError(), KalturaBatchJobStatus::RETRY);
                     $curlWrapper->close();
                     return $job;
                 }
             }
         }
         $curlWrapper->close();
         if (!file_exists($data->destFileLocalPath)) {
             $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::OUTPUT_FILE_DOESNT_EXIST, "Error: output file doesn't exist", KalturaBatchJobStatus::RETRY);
             return $job;
         }
         // check the file size only if its first or second retry
         // in case it failed few times, taks the file as is
         if ($fileSize) {
             clearstatcache();
             $actualFileSize = kFile::fileSize($data->destFileLocalPath);
             if ($actualFileSize < $fileSize) {
                 $percent = floor($actualFileSize * 100 / $fileSize);
                 $this->updateJob($job, "Downloaded size: {$actualFileSize}({$percent}%)", KalturaBatchJobStatus::PROCESSING, $data);
                 self::$kClient->batch->resetJobExecutionAttempts($job->id, $this->getExclusiveLockKey(), $job->jobType);
                 //					$this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::OUTPUT_FILE_WRONG_SIZE, "Expected file size[$fileSize] actual file size[$actualFileSize]", KalturaBatchJobStatus::RETRY);
                 return $job;
             }
             KalturaLog::info("headers " . print_r($curlHeaderResponse, true));
             $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaImportHandler');
             foreach ($pluginInstances as $pluginInstance) {
                 /* @var $pluginInstance IKalturaImportHandler */
                 $data = $pluginInstance->handleImportContent($curlHeaderResponse, $data, KBatchBase::$taskConfig->params);
             }
         }
         $this->updateJob($job, 'File imported, copy to shared folder', KalturaBatchJobStatus::PROCESSED);
         $job = $this->moveFile($job, $data->destFileLocalPath);
     } catch (kTemporaryException $tex) {
         $data->destFileLocalPath = KalturaClient::getKalturaNullValue();
         $tex->setData($data);
         throw $tex;
     } catch (Exception $ex) {
         $data->destFileLocalPath = KalturaClient::getKalturaNullValue();
         if ($ex->getMessage() == KCurlWrapper::COULD_NOT_CONNECT_TO_HOST_ERROR) {
             throw new kTemporaryException($ex->getMessage(), $ex->getCode(), $data);
         }
         $this->closeJob($job, KalturaBatchJobErrorTypes::RUNTIME, $ex->getCode(), "Error: " . $ex->getMessage(), KalturaBatchJobStatus::FAILED, $data);
     }
     return $job;
 }
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:KAsyncImport.class.php


注:本文中的KalturaClient::getKalturaNullValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。