[CONFIG][TWIG] Move twig config to php code to add support for placing templates in modules (plugins and components)

This commit is contained in:
Hugo Sales 2021-04-15 11:42:45 +00:00
parent a220d07b0f
commit 566c7694b5
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 8 additions and 5 deletions

View File

@ -1,4 +0,0 @@
twig:
paths:
'%kernel.project_dir%/templates': default_path
"%kernel.project_dir%/public": public_path

View File

@ -62,7 +62,7 @@ abstract class Module
if (!$note->isVisibleTo($user)) {
// ^ Ensure user isn't trying to trip us up
Log::error('Suspicious activity: user ' . $user->getNickname() .
' tried to repeat note ' . $note->getId() .
' tried to interact with note ' . $note->getId() .
', but they shouldn\'t have access to it');
throw new NoSuchNoteException();
} else {

View File

@ -112,6 +112,13 @@ class Kernel extends BaseKernel
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
$module_templates = array_merge(glob(INSTALLDIR . '/components/*/templates'), glob(INSTALLDIR . '/plugins/*/templates'));
$templates = ['%kernel.project_dir%/templates' => 'default_path', '%kernel.project_dir%/public' => 'public_path'];
foreach ($module_templates as $t) {
$templates[$t] = null;
}
$container->loadFromExtension('twig', ['paths' => $templates]);
// Overriding doesn't work as we want, overrides the top-most key, do it manually
$local_file = INSTALLDIR . '/social.local.yaml';
if (!file_exists($local_file)) {