Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,144 +0,0 @@
1
-<?php declare(strict_types=1);
2
-/**
3
- * Part of windwalker project.
4
- *
5
- * @copyright  Copyright (C) 2019 LYRASOFT.
6
- * @license    LGPL-2.0-or-later
7
- */
8
-
9
-namespace Windwalker\Renderer;
10
-
11
-use League\Plates\Engine as PlatesEngine;
12
-use League\Plates\Extension\ExtensionInterface;
13
-
14
-/**
15
- * The PlatesRenderer class.
16
- *
17
- * @since  2.0.9
18
- */
19
-class PlatesRenderer extends AbstractEngineRenderer
20
-{
21
-    /**
22
-     * Property extensions.
23
-     *
24
-     * @var  ExtensionInterface[]
25
-     */
26
-    protected $extensions = [];
27
-
28
-    /**
29
-     * Property folders.
30
-     *
31
-     * @var  array
32
-     */
33
-    protected $folders = [];
34
-
35
-    /**
36
-     * Method to get property Engine
37
-     *
38
-     * @param   boolean $new
39
-     *
40
-     * @return  PlatesEngine
41
-     */
42
-    public function getEngine($new = false)
43
-    {
44
-        if (!$this->engine || $new) {
45
-            $this->engine = new PlatesEngine(
46
-                dirname($this->config->get('path.found')),
47
-                ltrim($this->config->get('extension', '.tpl'), '.')
48
-            );
49
-
50
-            foreach ($this->folders as $namespace => $folder) {
51
-                $this->engine->addFolder($namespace, $folder['folder'], $folder['fallback']);
52
-            }
53
-
54
-            foreach ($this->extensions as $extension) {
55
-                $this->engine->loadExtension($extension);
56
-            }
57
-        }
58
-
59
-        return $this->engine;
60
-    }
61
-
62
-    /**
63
-     * Method to set property engine
64
-     *
65
-     * @param   PlatesEngine $engine
66
-     *
67
-     * @return  static  Return self to support chaining.
68
-     */
69
-    public function setEngine($engine)
70
-    {
71
-        if (!($engine instanceof PlatesEngine)) {
72
-            throw new \InvalidArgumentException('Engine object should be Mustache_Engine');
73
-        }
74
-
75
-        $this->engine = $engine;
76
-
77
-        return $this;
78
-    }
79
-
80
-    /**
81
-     * render
82
-     *
83
-     * @param string $file
84
-     * @param array  $data
85
-     *
86
-     * @return  string
87
-     */
88
-    public function render($file, $data = [])
89
-    {
90
-        $path = $this->findFile($file);
91
-
92
-        $this->config->set('path.found', $path);
93
-
94
-        return $this->getEngine()->render($file, $data);
95
-    }
96
-
97
-    /**
98
-     * findFile
99
-     *
100
-     * @param string $file
101
-     * @param string $ext
102
-     *
103
-     * @return  string
104
-     */
105
-    public function findFile($file, $ext = '')
106
-    {
107
-        $ext = $ext ?: $this->config->get('extension', 'tpl');
108
-
109
-        return parent::findFile($file, $ext);
110
-    }
111
-
112
-    /**
113
-     * addExtension
114
-     *
115
-     * @param ExtensionInterface $extension
116
-     *
117
-     * @return  static
118
-     */
119
-    public function addExtension(ExtensionInterface $extension)
120
-    {
121
-        $this->extensions[] = $extension;
122
-
123
-        return $this;
124
-    }
125
-
126
-    /**
127
-     * addFolder
128
-     *
129
-     * @param   string  $namespace
130
-     * @param   string  $folder
131
-     * @param   boolean $fallback
132
-     *
133
-     * @return  static
134
-     */
135
-    public function addFolder($namespace, $folder, $fallback = false)
136
-    {
137
-        $this->folders[$namespace] = [
138
-            'folder' => $folder,
139
-            'fallback' => $fallback,
140
-        ];
141
-
142
-        return $this;
143
-    }
144
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,144 @@
1
+<?php declare(strict_types=1);
2
+/**
3
+ * Part of windwalker project.
4
+ *
5
+ * @copyright  Copyright (C) 2019 LYRASOFT.
6
+ * @license    LGPL-2.0-or-later
7
+ */
8
+
9
+namespace Windwalker\Renderer;
10
+
11
+use League\Plates\Engine as PlatesEngine;
12
+use League\Plates\Extension\ExtensionInterface;
13
+
14
+/**
15
+ * The PlatesRenderer class.
16
+ *
17
+ * @since  2.0.9
18
+ */
19
+class PlatesRenderer extends AbstractEngineRenderer
20
+{
21
+    /**
22
+     * Property extensions.
23
+     *
24
+     * @var  ExtensionInterface[]
25
+     */
26
+    protected $extensions = [];
27
+
28
+    /**
29
+     * Property folders.
30
+     *
31
+     * @var  array
32
+     */
33
+    protected $folders = [];
34
+
35
+    /**
36
+     * Method to get property Engine
37
+     *
38
+     * @param   boolean $new
39
+     *
40
+     * @return  PlatesEngine
41
+     */
42
+    public function getEngine($new = false)
43
+    {
44
+        if (!$this->engine || $new) {
45
+            $this->engine = new PlatesEngine(
46
+                dirname($this->config->get('path.found')),
47
+                ltrim($this->config->get('extension', '.tpl'), '.')
48
+            );
49
+
50
+            foreach ($this->folders as $namespace => $folder) {
51
+                $this->engine->addFolder($namespace, $folder['folder'], $folder['fallback']);
52
+            }
53
+
54
+            foreach ($this->extensions as $extension) {
55
+                $this->engine->loadExtension($extension);
56
+            }
57
+        }
58
+
59
+        return $this->engine;
60
+    }
61
+
62
+    /**
63
+     * Method to set property engine
64
+     *
65
+     * @param   PlatesEngine $engine
66
+     *
67
+     * @return  static  Return self to support chaining.
68
+     */
69
+    public function setEngine($engine)
70
+    {
71
+        if (!($engine instanceof PlatesEngine)) {
72
+            throw new \InvalidArgumentException('Engine object should be Mustache_Engine');
73
+        }
74
+
75
+        $this->engine = $engine;
76
+
77
+        return $this;
78
+    }
79
+
80
+    /**
81
+     * render
82
+     *
83
+     * @param string $file
84
+     * @param array  $data
85
+     *
86
+     * @return  string
87
+     */
88
+    public function render($file, $data = [])
89
+    {
90
+        $path = $this->findFile($file);
91
+
92
+        $this->config->set('path.found', $path);
93
+
94
+        return $this->getEngine()->render($file, $data);
95
+    }
96
+
97
+    /**
98
+     * findFile
99
+     *
100
+     * @param string $file
101
+     * @param string $ext
102
+     *
103
+     * @return  string
104
+     */
105
+    public function findFile($file, $ext = '')
106
+    {
107
+        $ext = $ext ?: $this->config->get('extension', 'tpl');
108
+
109
+        return parent::findFile($file, $ext);
110
+    }
111
+
112
+    /**
113
+     * addExtension
114
+     *
115
+     * @param ExtensionInterface $extension
116
+     *
117
+     * @return  static
118
+     */
119
+    public function addExtension(ExtensionInterface $extension)
120
+    {
121
+        $this->extensions[] = $extension;
122
+
123
+        return $this;
124
+    }
125
+
126
+    /**
127
+     * addFolder
128
+     *
129
+     * @param   string  $namespace
130
+     * @param   string  $folder
131
+     * @param   boolean $fallback
132
+     *
133
+     * @return  static
134
+     */
135
+    public function addFolder($namespace, $folder, $fallback = false)
136
+    {
137
+        $this->folders[$namespace] = [
138
+            'folder' => $folder,
139
+            'fallback' => $fallback,
140
+        ];
141
+
142
+        return $this;
143
+    }
144
+}