/**
  * @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";
     }
 }
Exemplo n.º 2
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);
 }