aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-10-26 17:06:53 +0200
committerWilly Micieli <micieli@laposte.net>2019-10-26 17:06:53 +0200
commit74b8d02d32dd3f5f14244083b303ce5f8cd98d0b (patch)
tree9ceae9ba4f7a27258f2f46c07eaeb421cada7594
parentfc8879ac5b7d6f1c00012919cb718ba4cd298832 (diff)
downloadimperium-74b8d02d32dd3f5f14244083b303ce5f8cd98d0b.zip
imperium-74b8d02d32dd3f5f14244083b303ce5f8cd98d0b.tar.gz
add possibilities to extends twig10.5.2
-rw-r--r--README.md4
-rw-r--r--imperium/View/View.php24
2 files changed, 18 insertions, 10 deletions
diff --git a/README.md b/README.md
index 71187ee..720d8f3 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ It's a library written to be useful for everybody, in order to manage dbs and to
`composer require imperium/imperium`
* [**Source code**](https://git.fumseck.eu/cgit/imperium)
- * [**Download**](https://git.fumseck.eu/cgit/imperium/snapshot/imperium-10.5.1.zip)
+ * [**Download**](https://git.fumseck.eu/cgit/imperium/snapshot/imperium-10.5.2.zip)
* [**Report a bug**](mailto:bugzilla@laposte.net)
- * [**Show diff**](https://git.fumseck.eu/cgit/imperium/diff/?id=10.5.1&id2=10.5&dt=2)
+ * [**Show diff**](https://git.fumseck.eu/cgit/imperium/diff/?id=10.5.2&id2=10.5.1&dt=2)
diff --git a/imperium/View/View.php b/imperium/View/View.php
index c278dc6..ff0a6ae 100644
--- a/imperium/View/View.php
+++ b/imperium/View/View.php
@@ -3,14 +3,12 @@
namespace Imperium\View
{
- use DI\DependencyException;
- use DI\NotFoundException;
use Imperium\Cookies\Cookies;
use Imperium\Exception\Kedavra;
use Imperium\Flash\Flash;
use Sinergi\BrowserDetector\Os;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
- use Twig\Environment;
+ use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
@@ -70,10 +68,8 @@
*
* @param array $config
*
- * @throws DependencyException
* @throws Kedavra
* @throws LoaderError
- * @throws NotFoundException
*/
public function __construct(string $views_path, array $config)
{
@@ -100,7 +96,7 @@
$this->twig->addExtension(new ArrayExtension());
$this->twig->addExtension(new TranslationExtension());
-
+
$this->loader()->addPath($views_path . DIRECTORY_SEPARATOR . 'crud', 'crud');
$this->loader()->addPath($views_path . DIRECTORY_SEPARATOR . 'todo', 'todo');
@@ -201,6 +197,19 @@
bind_textdomain_codeset($this->domain(), 'UTF-8');
textdomain($this->domain());
+
+ $this->add_functions(glob(base('twig').DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR .'*.php'));
+
+ $this->add_filters(glob(base('twig').DIRECTORY_SEPARATOR.'filters'.DIRECTORY_SEPARATOR .'*.php'));
+
+ $this->add_globals(glob(base('twig').DIRECTORY_SEPARATOR.'globals'.DIRECTORY_SEPARATOR .'*.php'));
+
+ $this->add_test(glob(base('twig').DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR .'*.php'));
+
+ $this->add_tags(glob(base('twig').DIRECTORY_SEPARATOR.'tags'.DIRECTORY_SEPARATOR .'*.php'));
+
+ $this->add_extensions(glob(base('twig').DIRECTORY_SEPARATOR.'extensions'.DIRECTORY_SEPARATOR .'*.php'));
+
}
/**
@@ -331,7 +340,6 @@
*
* @param array $extensions
*
- *
*/
public function add_tags(array $extensions) : void
{
@@ -342,7 +350,7 @@
/**
* @param array $functions
*/
- public function add_functions(array $functions)
+ public function add_functions(array $functions): void
{
foreach($functions as $function)
$this->twig()->addFunction($function);