Skip to content

Commit

Permalink
Merge branch 'v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
maartendekeizer committed Dec 29, 2017
2 parents dda5fd4 + a9abadf commit fc0243a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
21 changes: 20 additions & 1 deletion src/Markei/SilexWebsiteFramework/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Markei\SilexWebsiteFramework\Controllers\ErrorController;
use Markei\SilexWebsiteFramework\Twig\ImagineExtension;
use Markei\SilexWebsiteFramework\Twig\ConfigExtension;
use Silex\Provider\CsrfServiceProvider;
use Symfony\Component\Form\FormRenderer;

/**
* @author maartendekeizer
Expand Down Expand Up @@ -82,6 +84,7 @@ public function boot()
{
parent::boot();
$this->bootTwig();
$this->bootDatabase();
$this->bootForm();
$this->bootTranslation();
$this->bootSwiftmailer();
Expand All @@ -100,6 +103,12 @@ protected function bootTwig()
$options['twig.options']['cache'] = $this['app.cache'] . DIRECTORY_SEPARATOR . 'twig';
}
$this->register(new TwigServiceProvider(), $options);
// patch for SF 3.4 break / https://github.com/silexphp/Silex/issues/1579
$this->extend('twig.runtimes', function ($runtimes, $app) {
return array_merge($runtimes, [
FormRenderer::class => 'twig.form.renderer',
]);
});
$this->extend('twig', function (\Twig_Environment $twig, Application $app) {
$twig->addExtension(new ImagineExtension($app));
$twig->addExtension(new ConfigExtension($app));
Expand All @@ -114,6 +123,7 @@ protected function bootForm()
{
$this->register(new FormServiceProvider(), array('form.secret' => $this['form.secret']));
$this->register(new ValidatorServiceProvider(), array());
$this->register(new CsrfServiceProvider());
}

/**
Expand Down Expand Up @@ -142,7 +152,16 @@ protected function bootSwiftmailer()
));
}

/**
/**
* Boots the Database Service Provider
* It's empty by default, please override with your own implementation
*/
protected function bootDatabase()
{
//
}

/**
* Get an array of options for Twig configuration
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function internalServerErrorAction(\Exception $e)
{
$parameters = array(
'message' => $e->getMessage(),
'debug' => $this->app['debug']
'debug' => $this->app['debug'],
'trace' => $e->getTraceAsString()
);

return $this->twig->render('Error/internalServerError.html.twig', $parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<p>An internal server error occurred. Please try again later.</p>
{% if debug %}
<h2>Debug information (only available when debug is activated)</h2>
<p class="error-message">{{ message }}</p>
<p class="error-message"><strong>{{ message }}</strong></p>
<p class="error-message">{{ trace|nl2br }}</p>
{% endif %}
{% endblock %}

0 comments on commit fc0243a

Please sign in to comment.