Skip to content

Commit

Permalink
feat: templates for error pages (404 and default)
Browse files Browse the repository at this point in the history
Main app can still override them in templates/bundles/TwigBundle
  • Loading branch information
williarin committed Aug 28, 2021
1 parent 0e6d19d commit 9fe11cf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/DependencyInjection/NumberNineChapterOneExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ public function prepend(ContainerBuilder $container): void

$container->prependExtensionConfig($name, $config);
}

$paths = [];
$appPath = '%kernel.project_dir%/templates/bundles/TwigBundle';
$themePath = '%kernel.project_dir%/vendor/numberninecms/chapterone/src/Resources/views/bundles/TwigBundle';
/** @var string $projectDir */
$projectDir = $container->getParameter('kernel.project_dir');

if (is_dir(str_replace('%kernel.project_dir%', $projectDir, $appPath))) {
$paths[$appPath] = 'Twig';
}

$paths[$themePath] = 'Twig';
$container->loadFromExtension('twig', ['paths' => $paths]);
}

public function loadInternal(array $mergedConfig, ContainerBuilder $container): void
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
twig:
form_themes: ['@ChapterOne/form/tailwind_layout.html.twig']
form_themes: ['@NumberNineChapterOne/form/tailwind_layout.html.twig']

framework:
assets:
Expand Down
13 changes: 13 additions & 0 deletions src/Resources/views/bundles/TwigBundle/Exception/error.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% trans_default_domain 'ChapterOne' %}
{% extends N9_base_template() %}

{% block body %}
<div class="container standard-container">
<main class="px-3 mb-10">
<h1 class="text-header">{{ 'An error occured.'|trans }}</h1>
{{ N9_shortcode('[divider]') }}
<p class="text-xl mb-5">{{ "Something is broken. Please let us know what you were doing when this error occurred.\nWe will fix it as soon as possible. Sorry for any inconvenience caused."|trans|nl2br }}</p>
<p>{{ 'Error code: %1%'|trans({'%1%': status_code}) }}</p>
</main>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% trans_default_domain 'ChapterOne' %}
{% extends N9_base_template() %}

{% block body %}
<div class="container standard-container">
<main class="px-3 mb-10">
<h1 class="text-header">{{ 'Page not found.'|trans }}</h1>
{{ N9_shortcode('[divider]') }}
<p class="text-xl">{{ "We can't seem to find the page you're looking for."|trans }}</p>
</main>
</div>
{% endblock %}

0 comments on commit 9fe11cf

Please sign in to comment.