/** * Builds a list of screenshots. * * @param StyleInterface $style A style for which screenshots list should be * built. * @return array List of available screenshots. Each element is an * associative array with the following keys: * - "name": string, name of the screenshot. * - "file": string, URL of the screenshot. * - "description" string, screenshots description. */ protected function buildScreenshotList(StyleInterface $style) { $base_path = $style->getFilesPath() . '/screenshots'; $style_config = $style->getConfigurations(); $screenshots = array(); foreach ($style_config['screenshots'] as $name => $desc) { $screenshots[] = array('name' => $name, 'file' => $this->asset($base_path . '/' . $name . '.png'), 'description' => $desc); } return $screenshots; }
/** * Prepares a style right after creation. * * One can use this method to add custom helpers to a template engine using * by the style. * * @param StyleInterface $style A style that should be prepared. * @return StyleInterface A ready to use style instance. */ protected function prepareStyle(StyleInterface $style) { if ($style instanceof HandlebarsAwareInterface) { $hbs = $style->getHandlebars(); // Use mibew cache to store Handlebars AST $hbs->setCache(new HandlebarsCacheAdapter($this->getCache())); // Add more helpers to template engine $hbs->addHelper('route', new RouteHelper($this)); $hbs->addHelper('csrfProtectedRoute', new CsrfProtectedRouteHelper($this)); $hbs->addHelper('asset', new AssetHelper($this, array('CurrentStyle' => $style->getFilesPath()))); $hbs->addHelper('jsAssets', new JsAssetsHelper($this)); $hbs->addHelper('cssAssets', new CssAssetsHelper($this)); } return $style; }