Completed
Pull Request — 2.0.x (#6)
by Andrew
02:09
created
classes/Ingenerator/KohanaView/ViewModel/PageContentView.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
 interface PageContentView extends ViewModel
22 22
 {
23 23
 
24
-    /**
25
-     * The page layout that this content view will be rendered into
26
-     *
27
-     * @return PageLayoutView
28
-     */
29
-    public function var_page();
24
+	/**
25
+	 * The page layout that this content view will be rendered into
26
+	 *
27
+	 * @return PageLayoutView
28
+	 */
29
+	public function var_page();
30 30
 }
Please login to merge, or discard this patch.
Ingenerator/KohanaView/ViewModel/PageLayout/AbstractPageContentView.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author     Andrew Coulton <[email protected]>
4
- * @copyright  2015 inGenerator Ltd
5
- * @license    http://kohanaframework.org/license
6
- */
3
+	 * @author     Andrew Coulton <[email protected]>
4
+	 * @copyright  2015 inGenerator Ltd
5
+	 * @license    http://kohanaframework.org/license
6
+	 */
7 7
 
8 8
 namespace Ingenerator\KohanaView\ViewModel\PageLayout;
9 9
 
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
 abstract class AbstractPageContentView extends AbstractViewModel implements PageContentView
28 28
 {
29 29
 
30
-    /**
31
-     * @var PageLayoutView
32
-     */
33
-    protected $page_view;
34
-
35
-    public function __construct(PageLayoutView $page)
36
-    {
37
-        $this->page_view = $page;
38
-        parent::__construct();
39
-    }
40
-
41
-    /**
42
-     * @return PageLayoutView
43
-     */
44
-    public function var_page()
45
-    {
46
-        return $this->page_view;
47
-    }
30
+	/**
31
+	 * @var PageLayoutView
32
+	 */
33
+	protected $page_view;
34
+
35
+	public function __construct(PageLayoutView $page)
36
+	{
37
+		$this->page_view = $page;
38
+		parent::__construct();
39
+	}
40
+
41
+	/**
42
+	 * @return PageLayoutView
43
+	 */
44
+	public function var_page()
45
+	{
46
+		return $this->page_view;
47
+	}
48 48
 
49 49
 }
Please login to merge, or discard this patch.
Ingenerator/KohanaView/ViewModel/PageLayout/AbstractPageLayoutView.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,32 +26,32 @@
 block discarded – undo
26 26
 abstract class AbstractPageLayoutView extends AbstractViewModel implements ViewModel\PageLayoutView
27 27
 {
28 28
 
29
-    /**
30
-     * @var array
31
-     */
32
-    protected $variables = [
33
-        'body_html' => NULL,
34
-        'title'     => NULL,
35
-    ];
36
-
37
-    /**
38
-     * @param string $title
39
-     *
40
-     * @return void
41
-     */
42
-    public function setTitle($title)
43
-    {
44
-        $this->variables['title'] = $title;
45
-    }
46
-
47
-    /**
48
-     * @param string $html
49
-     *
50
-     * @return void
51
-     */
52
-    public function setBodyHTML($html)
53
-    {
54
-        $this->variables['body_html'] = $html;
55
-    }
29
+	/**
30
+	 * @var array
31
+	 */
32
+	protected $variables = [
33
+		'body_html' => NULL,
34
+		'title'     => NULL,
35
+	];
36
+
37
+	/**
38
+	 * @param string $title
39
+	 *
40
+	 * @return void
41
+	 */
42
+	public function setTitle($title)
43
+	{
44
+		$this->variables['title'] = $title;
45
+	}
46
+
47
+	/**
48
+	 * @param string $html
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public function setBodyHTML($html)
53
+	{
54
+		$this->variables['body_html'] = $html;
55
+	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/ViewModel/PageLayoutView.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
 interface PageLayoutView extends ViewModel
22 22
 {
23 23
 
24
-    /**
25
-     * @param string $html
26
-     *
27
-     * @return void
28
-     */
29
-    public function setBodyHTML($html);
24
+	/**
25
+	 * @param string $html
26
+	 *
27
+	 * @return void
28
+	 */
29
+	public function setBodyHTML($html);
30 30
 
31 31
 }
Please login to merge, or discard this patch.
Ingenerator/KohanaView/ViewModel/PageLayout/StaticPageContentView.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
 
12 12
 class StaticPageContentView extends AbstractPageContentView implements TemplateSpecifyingViewModel
13 13
 {
14
-    protected $variables = [
15
-        'page_path' => NULL,
16
-    ];
14
+	protected $variables = [
15
+		'page_path' => NULL,
16
+	];
17 17
 
18
-    /**
19
-     * {@inheritdoc}
20
-     */
21
-    public function getTemplateName()
22
-    {
23
-        if ( ! $this->variables['page_path']) {
24
-            throw new \BadMethodCallException(
25
-                'Call '.static::class.'::display(["page_path" => "name/of/view"]) before rendering static views'
26
-            );
27
-        }
18
+	/**
19
+	 * {@inheritdoc}
20
+	 */
21
+	public function getTemplateName()
22
+	{
23
+		if ( ! $this->variables['page_path']) {
24
+			throw new \BadMethodCallException(
25
+				'Call '.static::class.'::display(["page_path" => "name/of/view"]) before rendering static views'
26
+			);
27
+		}
28 28
 
29
-        return $this->variables['page_path'];
30
-    }
29
+		return $this->variables['page_path'];
30
+	}
31 31
 
32 32
 
33 33
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/Renderer/PageLayoutRenderer.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -34,82 +34,82 @@
 block discarded – undo
34 34
  */
35 35
 class PageLayoutRenderer
36 36
 {
37
-    /**
38
-     * @var bool Whether to force (or not force) embedding the content in the layout
39
-     */
40
-    protected $use_layout;
37
+	/**
38
+	 * @var bool Whether to force (or not force) embedding the content in the layout
39
+	 */
40
+	protected $use_layout;
41 41
 
42
-    /**
43
-     * @var Renderer
44
-     */
45
-    protected $view_renderer;
42
+	/**
43
+	 * @var Renderer
44
+	 */
45
+	protected $view_renderer;
46 46
 
47
-    /**
48
-     * @var \Request
49
-     */
50
-    protected $current_request;
47
+	/**
48
+	 * @var \Request
49
+	 */
50
+	protected $current_request;
51 51
 
52
-    public function __construct(Renderer $view_renderer, \Request $current_request = NULL)
53
-    {
54
-        $this->view_renderer   = $view_renderer;
55
-        $this->current_request = $current_request;
56
-    }
52
+	public function __construct(Renderer $view_renderer, \Request $current_request = NULL)
53
+	{
54
+		$this->view_renderer   = $view_renderer;
55
+		$this->current_request = $current_request;
56
+	}
57 57
 
58
-    /**
59
-     * @param PageContentView $content_view
60
-     *
61
-     * @return string
62
-     */
63
-    public function render(PageContentView $content_view)
64
-    {
65
-        $content = $this->view_renderer->render($content_view);
66
-        if ($this->shouldUseLayout()) {
67
-            return $this->renderInLayout($content_view->var_page(), $content);
68
-        } else {
69
-            return $content;
70
-        }
71
-    }
58
+	/**
59
+	 * @param PageContentView $content_view
60
+	 *
61
+	 * @return string
62
+	 */
63
+	public function render(PageContentView $content_view)
64
+	{
65
+		$content = $this->view_renderer->render($content_view);
66
+		if ($this->shouldUseLayout()) {
67
+			return $this->renderInLayout($content_view->var_page(), $content);
68
+		} else {
69
+			return $content;
70
+		}
71
+	}
72 72
 
73
-    /**
74
-     * @return bool
75
-     */
76
-    protected function shouldUseLayout()
77
-    {
78
-        if ($this->use_layout !== NULL) {
79
-            return $this->use_layout;
80
-        }
73
+	/**
74
+	 * @return bool
75
+	 */
76
+	protected function shouldUseLayout()
77
+	{
78
+		if ($this->use_layout !== NULL) {
79
+			return $this->use_layout;
80
+		}
81 81
 
82
-        if ($this->current_request AND $this->current_request->is_ajax()) {
83
-            return FALSE;
84
-        } else {
85
-            return TRUE;
86
-        }
87
-    }
82
+		if ($this->current_request AND $this->current_request->is_ajax()) {
83
+			return FALSE;
84
+		} else {
85
+			return TRUE;
86
+		}
87
+	}
88 88
 
89
-    /**
90
-     * @param PageLayoutView $layout
91
-     * @param string         $content
92
-     *
93
-     * @return string
94
-     */
95
-    protected function renderInLayout(PageLayoutView $layout, $content)
96
-    {
97
-        $layout->setBodyHTML($content);
89
+	/**
90
+	 * @param PageLayoutView $layout
91
+	 * @param string         $content
92
+	 *
93
+	 * @return string
94
+	 */
95
+	protected function renderInLayout(PageLayoutView $layout, $content)
96
+	{
97
+		$layout->setBodyHTML($content);
98 98
 
99
-        return $this->view_renderer->render($layout);
100
-    }
99
+		return $this->view_renderer->render($layout);
100
+	}
101 101
 
102
-    /**
103
-     * Configure whether to always wrap the content in the layout (TRUE), never (FALSE) or automatically for
104
-     * non-AJAX requests (NULL)
105
-     *
106
-     * @param bool $use_layout
107
-     *
108
-     * @return void
109
-     */
110
-    public function setUseLayout($use_layout)
111
-    {
112
-        $this->use_layout = $use_layout;
113
-    }
102
+	/**
103
+	 * Configure whether to always wrap the content in the layout (TRUE), never (FALSE) or automatically for
104
+	 * non-AJAX requests (NULL)
105
+	 *
106
+	 * @param bool $use_layout
107
+	 *
108
+	 * @return void
109
+	 */
110
+	public function setUseLayout($use_layout)
111
+	{
112
+		$this->use_layout = $use_layout;
113
+	}
114 114
 
115 115
 }
Please login to merge, or discard this patch.
classes/Ingenerator/KohanaView/TemplateManager/CFSTemplateManager.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -22,117 +22,117 @@
 block discarded – undo
22 22
  */
23 23
 class CFSTemplateManager implements TemplateManager
24 24
 {
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $cache_dir;
29
-
30
-    /**
31
-     * @var CFSWrapper
32
-     */
33
-    protected $cascading_files;
34
-
35
-    /**
36
-     * @var array
37
-     */
38
-    protected $compiled_paths = [];
39
-
40
-    /**
41
-     * @var TemplateCompiler
42
-     */
43
-    protected $compiler;
44
-
45
-    /**
46
-     * @var boolean
47
-     */
48
-    protected $recompile_always;
49
-
50
-    /**
51
-     * Valid options:
52
-     * * cache_dir => the path where compiled templates will be cached
53
-     * * recompile_always => whether to recompile each template on every execution,
54
-     *
55
-     * @param TemplateCompiler $compiler
56
-     * @param array            $options
57
-     * @param CFSWrapper       $cascading_files
58
-     */
59
-    public function __construct(TemplateCompiler $compiler, array $options, CFSWrapper $cascading_files = NULL)
60
-    {
61
-        $this->cascading_files  = $cascading_files ?: new CFSWrapper;
62
-        $this->compiler         = $compiler;
63
-        $this->cache_dir        = trim($options['cache_dir'], '/');
64
-        $this->recompile_always = \Arr::get($options, 'recompile_always', FALSE);
65
-    }
66
-
67
-    /**
68
-     * {@inheritdoc}
69
-     */
70
-    public function getPath($template_name)
71
-    {
72
-        $compiled_path = $this->cache_dir.'/'.$template_name.'.php';
73
-
74
-        if ($this->isCompileRequired($compiled_path)) {
75
-            $source   = $this->requireSourceFileContent($template_name);
76
-            $compiled = $this->compiler->compile($source);
77
-            $this->writeFile($compiled_path, $compiled);
78
-            $this->compiled_paths[$compiled_path] = TRUE;
79
-        }
80
-
81
-        return $compiled_path;
82
-    }
83
-
84
-    /**
85
-     * @param string $compiled_path
86
-     *
87
-     * @return bool
88
-     */
89
-    protected function isCompileRequired($compiled_path)
90
-    {
91
-        if ($this->recompile_always AND ! isset($this->compiled_paths[$compiled_path])) {
92
-            return TRUE;
93
-        }
94
-
95
-        return ! file_exists($compiled_path);
96
-    }
97
-
98
-    /**
99
-     * @param string $template_name
100
-     *
101
-     * @return string
102
-     */
103
-    protected function requireSourceFileContent($template_name)
104
-    {
105
-        if ( ! $source_file = $this->cascading_files->find_file('views', $template_name)) {
106
-            throw new \InvalidArgumentException("Cannot find template source file 'views/$template_name'");
107
-        }
108
-
109
-        return file_get_contents($source_file);
110
-    }
111
-
112
-    /**
113
-     * @param string $compiled_path
114
-     * @param string $compiled
115
-     */
116
-    protected function writeFile($compiled_path, $compiled)
117
-    {
118
-        $this->ensureWriteableDirectory(dirname($compiled_path));
119
-        file_put_contents($compiled_path, $compiled);
120
-    }
121
-
122
-    /**
123
-     * @param string $path
124
-     */
125
-    protected function ensureWriteableDirectory($path)
126
-    {
127
-        if (is_dir($path)) {
128
-            if ( ! is_writeable($path)) {
129
-                throw new \RuntimeException("Cannot write to compiled template path '$path'");
130
-            }
131
-        } else {
132
-            if ( ! mkdir($path, 0777, TRUE)) {
133
-                throw new \RuntimeException("Cannot create template cache directory in '$path'");
134
-            }
135
-        }
136
-    }
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $cache_dir;
29
+
30
+	/**
31
+	 * @var CFSWrapper
32
+	 */
33
+	protected $cascading_files;
34
+
35
+	/**
36
+	 * @var array
37
+	 */
38
+	protected $compiled_paths = [];
39
+
40
+	/**
41
+	 * @var TemplateCompiler
42
+	 */
43
+	protected $compiler;
44
+
45
+	/**
46
+	 * @var boolean
47
+	 */
48
+	protected $recompile_always;
49
+
50
+	/**
51
+	 * Valid options:
52
+	 * * cache_dir => the path where compiled templates will be cached
53
+	 * * recompile_always => whether to recompile each template on every execution,
54
+	 *
55
+	 * @param TemplateCompiler $compiler
56
+	 * @param array            $options
57
+	 * @param CFSWrapper       $cascading_files
58
+	 */
59
+	public function __construct(TemplateCompiler $compiler, array $options, CFSWrapper $cascading_files = NULL)
60
+	{
61
+		$this->cascading_files  = $cascading_files ?: new CFSWrapper;
62
+		$this->compiler         = $compiler;
63
+		$this->cache_dir        = trim($options['cache_dir'], '/');
64
+		$this->recompile_always = \Arr::get($options, 'recompile_always', FALSE);
65
+	}
66
+
67
+	/**
68
+	 * {@inheritdoc}
69
+	 */
70
+	public function getPath($template_name)
71
+	{
72
+		$compiled_path = $this->cache_dir.'/'.$template_name.'.php';
73
+
74
+		if ($this->isCompileRequired($compiled_path)) {
75
+			$source   = $this->requireSourceFileContent($template_name);
76
+			$compiled = $this->compiler->compile($source);
77
+			$this->writeFile($compiled_path, $compiled);
78
+			$this->compiled_paths[$compiled_path] = TRUE;
79
+		}
80
+
81
+		return $compiled_path;
82
+	}
83
+
84
+	/**
85
+	 * @param string $compiled_path
86
+	 *
87
+	 * @return bool
88
+	 */
89
+	protected function isCompileRequired($compiled_path)
90
+	{
91
+		if ($this->recompile_always AND ! isset($this->compiled_paths[$compiled_path])) {
92
+			return TRUE;
93
+		}
94
+
95
+		return ! file_exists($compiled_path);
96
+	}
97
+
98
+	/**
99
+	 * @param string $template_name
100
+	 *
101
+	 * @return string
102
+	 */
103
+	protected function requireSourceFileContent($template_name)
104
+	{
105
+		if ( ! $source_file = $this->cascading_files->find_file('views', $template_name)) {
106
+			throw new \InvalidArgumentException("Cannot find template source file 'views/$template_name'");
107
+		}
108
+
109
+		return file_get_contents($source_file);
110
+	}
111
+
112
+	/**
113
+	 * @param string $compiled_path
114
+	 * @param string $compiled
115
+	 */
116
+	protected function writeFile($compiled_path, $compiled)
117
+	{
118
+		$this->ensureWriteableDirectory(dirname($compiled_path));
119
+		file_put_contents($compiled_path, $compiled);
120
+	}
121
+
122
+	/**
123
+	 * @param string $path
124
+	 */
125
+	protected function ensureWriteableDirectory($path)
126
+	{
127
+		if (is_dir($path)) {
128
+			if ( ! is_writeable($path)) {
129
+				throw new \RuntimeException("Cannot write to compiled template path '$path'");
130
+			}
131
+		} else {
132
+			if ( ! mkdir($path, 0777, TRUE)) {
133
+				throw new \RuntimeException("Cannot create template cache directory in '$path'");
134
+			}
135
+		}
136
+	}
137 137
 
138 138
 }
Please login to merge, or discard this patch.