Esempio n. 1
0
 public function directCustomImageCallable(PageInfo $pageInfo, RouteParams $routeInfo, \Auryn\Injector $injector, $params)
 {
     App::setupCategoryExample($routeInfo);
     $imageFunction = CategoryInfo::getCustomImageFunctionName($pageInfo);
     global $imageType;
     ob_start();
     $injector->execute($imageFunction);
     if ($imageType == null) {
         ob_end_clean();
         throw new \Exception("imageType not set, can't cache image correctly.");
     }
     $imageData = ob_get_contents();
     ob_end_clean();
     $simpleNameWithExtension = $pageInfo->getSimpleName($params) . '.' . $imageType;
     return new BlobBody($simpleNameWithExtension, $imageData, "image/" . $imageType);
 }
Esempio n. 2
0
 private function execute(ImagickTask $task)
 {
     $pageInfo = $task->getPageInfo();
     $params = $task->getParams();
     $filename = $this->imageCachePath->getImageCacheFilename($pageInfo, $params);
     $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 = App::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";
         var_dump($ie->getDependencyChain());
     }
 }