public function getCurrentName(PageInfo $pageInfo) { $exampleList = CategoryInfo::getCategoryList($pageInfo->getCategory()); $currentExample = $pageInfo->getExample(); foreach ($exampleList as $exampleName => $exampleDefinition) { if (strcasecmp($currentExample, $exampleName) === 0) { return $exampleName; } } return null; }
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); }
/** * @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"; } }
function directCustomImageCallable(PageInfo $pageInfo, \Auryn\Injector $injector, $params) { $imageFunction = CategoryInfo::getCustomImageFunctionName($pageInfo); $filename = getImageCacheFilename($pageInfo, $params); 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(); return new DataBody($filename, $imageData, "image/" . $imageType); }
public function renderVertical() { $output = "<ul class='nav nav-sidebar smallPadding' id='searchList'>"; $exampleList = CategoryInfo::getCategoryList($this->pageInfo->getCategory()); foreach ($exampleList as $exampleName => $exampleDefinition) { $imagickExample = $exampleName; //$imagickExampleOption->getName(); $active = ''; $activeLink = ''; if ($this->pageInfo->getExample() === $imagickExample) { $active = 'navActive'; $activeLink = 'navActiveLink'; } $name = $imagickExample; if (isset($exampleDefinition['name'])) { $name = $exampleDefinition['name']; } $output .= "<li class='navSpacer {$active}'>"; $output .= sprintf("<a class='smallPadding %s' href='/%s/%s'>%s</a>", $activeLink, $this->pageInfo->getCategory(), $imagickExample, $name); $output .= "</li>"; } $output .= "</ul>"; return $output; }
public static function createExample(PageInfo $pageInfo, Injector $injector) { $exampleName = CategoryInfo::getImageFunctionName($pageInfo); return $injector->make($exampleName); }