コード例 #1
0
ファイル: Image.php プロジェクト: sdmmember/Imagick-demos
function processImageTask(Request $request, $imageFunction, ImagickTaskQueue $taskQueue, $category, $example)
{
    //use ($params)
    $debug = 'Unknown state';
    $job = $request->getVariable('job', false);
    if ($job === false) {
        if ($taskQueue->isActive() == false) {
            //Queue isn't active - don't bother queueing a task
            return null;
        }
        $task = \ImagickDemo\Queue\ImagickTask::create($category, $example, $imageFunction, $params);
        $debug .= "task created.";
        $taskQueue->addTask($task);
    }
    if ($request->getVariable('noredirect') == true) {
        return new \ImagickDemo\Response\ErrorResponse(503, "image still processing {$job} is " . $job . $debug);
    }
    return redirectWaitingTask($request, intval($job));
}
コード例 #2
0
 /**
  * @param ImagickTask $task
  * @throws \Exception
  */
 private function execute(ImagickTask $task)
 {
     $pageInfo = $task->getPageInfo();
     $params = $task->getParams();
     $filename = $task->getFilename();
     $imageTypes = ['jpg', 'gif', 'png'];
     echo "file base name is {$filename}\n";
     foreach ($imageTypes as $imageType) {
         $fullFilename = $filename . "." . $imageType;
         if (file_exists($fullFilename) == true) {
             echo "File {$fullFilename} already exists - skipping generation\n";
             return;
         }
     }
     $injector = clone $this->injector;
     $lowried = [];
     foreach ($params as $key => $value) {
         $lowried[':' . $key] = $value;
     }
     $variableMap = new ArrayVariableMap($params);
     $injector->alias('Room11\\HTTP\\VariableMap', get_class($variableMap));
     $injector->share($variableMap);
     if ($task->isCustomImage()) {
         $imageFunction = CategoryInfo::getCustomImageFunctionName($pageInfo);
     } else {
         $imageFunction = CategoryInfo::getImageFunctionName($pageInfo);
     }
     $controlClassName = CategoryInfo::getControlClassName($pageInfo);
     if ($controlClassName) {
         $injector->alias('ImagickDemo\\Control', $controlClassName);
     }
     echo "Image Function name is: \n";
     var_dump($imageFunction);
     try {
         $result = renderImageAsFileResponse($imageFunction, $filename, $injector, $lowried);
         echo "file written: {$filename} \n";
     } catch (InjectionException $ie) {
         echo "InjectionException calling image function: " . var_export($imageFunction, true) . "\n";
         echo "Details: " . $ie->getMessage() . "\n";
     }
 }
コード例 #3
0
 /**
  * @param ImagickTask $task
  * @throws \Exception
  */
 private function execute(ImagickTask $task)
 {
     $imageFunction = $task->getImageFunction();
     $params = $task->getParams();
     $filename = $task->getFilename();
     $imageTypes = ['jpg', 'gif', 'png'];
     foreach ($imageTypes as $imageType) {
         $fullFilename = $filename . "." . $imageType;
         if (file_exists($fullFilename) == true) {
             return;
         }
     }
     $lowried = [];
     foreach ($params as $key => $value) {
         $lowried[':' . $key] = $value;
     }
     $injector = clone $this->injector;
     $variableMap = new ArrayVariableMap($params);
     $injector->alias('ImagickDemo\\Framework\\VariableMap', get_class($variableMap));
     $injector->share($variableMap);
     echo "filename was {$filename}\n";
     renderImageAsFileResponse($imageFunction, $filename, $injector, $lowried);
 }