本文整理汇总了PHP中Pimple\Container::edition方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::edition方法的具体用法?PHP Container::edition怎么用?PHP Container::edition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple\Container
的用法示例。
在下文中一共展示了Container::edition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register(Container $app)
{
$app['publisher'] = function ($app) {
$outputFormat = $app->edition('format');
switch (strtolower($outputFormat)) {
case 'pdf':
$publisher = new PdfPublisher($app);
break;
case 'html':
$publisher = new HtmlPublisher($app);
break;
case 'html_chunked':
$publisher = new HtmlChunkedPublisher($app);
break;
case 'epub':
$publisher = new Epub2Publisher($app);
break;
case 'mobi':
$publisher = new MobiPublisher($app);
break;
default:
throw new \RuntimeException(sprintf('Unknown "%s" format for "%s" edition (allowed: "pdf", "html", "html_chunked", "epub", "mobi")', $outputFormat, $app['publishing.edition']));
}
if (true !== $publisher->checkIfThisPublisherIsSupported()) {
throw new \RuntimeException(sprintf("Your system doesn't support publishing books with the '%s' format\n" . 'Check the easybook documentation to know the dependencies required by this format.', $outputFormat));
}
return $publisher;
};
}
示例2: register
public function register(Container $app)
{
$app['twig.options'] = array('autoescape' => false, 'charset' => $app['app.charset'], 'debug' => $app['app.debug'], 'strict_variables' => $app['app.debug']);
$app['twig.loader'] = function () use($app) {
$theme = ucfirst($app->edition('theme'));
$format = Toolkit::camelize($app->edition('format'), true);
$loader = new \Twig_Loader_Filesystem($app['app.dir.themes']);
// Base theme (common styles per edition type)
// <easybook>/app/Resources/Themes/Base/<edition-type>/Templates/<template-name>.twig
$baseThemeDir = sprintf('%s/Base/%s/Templates', $app['app.dir.themes'], $format);
$loader->addPath($baseThemeDir);
$loader->addPath($baseThemeDir, 'theme');
$loader->addPath($baseThemeDir, 'theme_base');
// Book theme (configured per edition in 'config.yml')
// <easybook>/app/Resources/Themes/<theme>/<edition-type>/Templates/<template-name>.twig
$bookThemeDir = sprintf('%s/%s/%s/Templates', $app['app.dir.themes'], $theme, $format);
$loader->prependPath($bookThemeDir);
$loader->prependPath($bookThemeDir, 'theme');
$userTemplatePaths = array($app['publishing.dir.templates'], sprintf('%s/%s', $app['publishing.dir.templates'], strtolower($format)), sprintf('%s/%s', $app['publishing.dir.templates'], $app['publishing.edition']));
foreach ($userTemplatePaths as $path) {
if (file_exists($path)) {
$loader->prependPath($path);
}
}
$defaultContentPaths = array(sprintf('%s/Base/%s/Contents', $app['app.dir.themes'], $format), sprintf('%s/%s/%s/Contents', $app['app.dir.themes'], $theme, $format));
foreach ($defaultContentPaths as $path) {
if (file_exists($path)) {
$loader->prependPath($path, 'content');
}
}
return $loader;
};
$app['twig'] = function () use($app) {
$twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
$twig->addExtension(new TwigCssExtension());
$twig->addGlobal('app', $app);
if (null !== ($bookConfig = $app['publishing.book.config'])) {
$twig->addGlobal('book', $bookConfig['book']);
$publishingEdition = $app['publishing.edition'];
$editions = $app->book('editions');
$twig->addGlobal('edition', $editions[$publishingEdition]);
}
return $twig;
};
}