本文整理汇总了PHP中Silex\Application::isProduction方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::isProduction方法的具体用法?PHP Application::isProduction怎么用?PHP Application::isProduction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::isProduction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* {@inheritdoc}
*/
public function register(Application $app)
{
$app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
/* @var Twig_Environment $twig */
$twig = $app['twig'];
$twig->addGlobal('current_page', function () use($app) {
return $app['request']->getRequestUri();
});
$twig->addGlobal('cfp_open', strtotime('now') < strtotime($app->config('application.enddate') . ' 11:59 PM'));
if (!$app->isProduction()) {
$twig->addExtension(new Twig_Extension_Debug());
}
$twig->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
return '/uploads/' . $path;
}));
$twig->addFunction(new Twig_SimpleFunction('assets', function ($path) {
return '/assets/' . $path;
}));
$twig->addGlobal('site', $app->config('application'));
// Twig Markdown Extension
$markdown = new Ciconia();
$markdown->addExtension(new InlineStyleExtension());
$markdown->addExtension(new WhiteSpaceExtension());
$engine = new CiconiaEngine($markdown);
$twig->addExtension(new MarkdownExtension($engine));
$twig->addGlobal('talkHelper', new TalkHelper($app->config('talk.categories'), $app->config('talk.levels'), $app->config('talk.types')));
}
示例2: register
/**
* {@inheritdoc}
*/
public function register(Application $app)
{
$app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
if (!$app->isProduction()) {
$app['twig']->addExtension(new Twig_Extension_Debug());
}
$app['twig']->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
return '/uploads/' . $path;
}));
$app['twig']->addFunction(new Twig_SimpleFunction('assets', function ($path) {
return '/assets/' . $path;
}));
$app['twig']->addGlobal('site', $app->config('application'));
// Twig Markdown Extension
$markdown = new Ciconia();
$markdown->addExtension(new InlineStyleExtension());
$markdown->addExtension(new WhiteSpaceExtension());
$engine = new CiconiaEngine($markdown);
$app['twig']->addExtension(new MarkdownExtension($engine));
}
示例3: register
/**
* {@inheritdoc}
*/
public function register(Application $app)
{
$app->register(new SilexTwigServiceProvider(), ['twig.path' => $app->templatesPath(), 'twig.options' => ['debug' => !$app->isProduction(), 'cache' => $app->config('cache.enabled') ? $app->cacheTwigPath() : false]]);
if ($app->isProduction()) {
$app->error(function (\Exception $e, $code) use($app) {
switch ($code) {
case 401:
$message = $app['twig']->render('error/401.twig');
break;
case 403:
$message = $app['twig']->render('error/403.twig');
break;
case 404:
$message = $app['twig']->render('error/404.twig');
break;
default:
$message = $app['twig']->render('error/500.twig');
}
return new Response($message, $code);
});
} else {
$app['twig']->addExtension(new Twig_Extension_Debug());
}
$app['twig']->addFunction(new Twig_SimpleFunction('uploads', function ($path) {
return '/uploads/' . $path;
}));
$app['twig']->addFunction(new Twig_SimpleFunction('assets', function ($path) {
return '/assets/' . $path;
}));
$app['twig']->addGlobal('site', $app->config('application'));
// Twig Markdown Extension
$markdown = new Ciconia();
$markdown->addExtension(new InlineStyleExtension());
$markdown->addExtension(new WhiteSpaceExtension());
$engine = new CiconiaEngine($markdown);
$app['twig']->addExtension(new MarkdownExtension($engine));
}