Completed
Pull Request — master (#286)
by Frank
07:37
created
plugins/phile/parserMeta/config.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * config file
4
- */
3
+     * config file
4
+     */
5 5
 return [
6 6
     'setting-example' => 'I love Phile!'
7 7
 ];
Please login to merge, or discard this patch.
lib/Phile/Session.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Session class
4
- */
3
+     * The Session class
4
+     */
5 5
 namespace Phile;
6 6
 
7 7
 /**
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
 ob_start();
12 12
 
13 13
 try {
14
-	\Phile\Bootstrap::getInstance()->initializeBasics();
15
-	$router = new \Phile\Core\Router();
16
-	$response = new \Phile\Core\Response();
17
-	$phileCore = new \Phile\Core($router, $response);
18
-	$phileCore->render();
14
+    \Phile\Bootstrap::getInstance()->initializeBasics();
15
+    $router = new \Phile\Core\Router();
16
+    $response = new \Phile\Core\Response();
17
+    $phileCore = new \Phile\Core($router, $response);
18
+    $phileCore->render();
19 19
 } catch (\Phile\Exception\AbstractException $e) {
20
-	if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
21
-		ob_end_clean();
20
+    if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
21
+        ob_end_clean();
22 22
 
23
-		/** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
24
-		$errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
25
-		$errorHandler->handleException($e);
26
-	}
23
+        /** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
24
+        $errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
25
+        $errorHandler->handleException($e);
26
+    }
27 27
 } catch (\Exception $e) {
28
-	if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
29
-		ob_end_clean();
28
+    if (\Phile\Core\ServiceLocator::hasService('Phile_ErrorHandler')) {
29
+        ob_end_clean();
30 30
 
31
-		/** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
32
-		$errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
33
-		$errorHandler->handleException($e);
34
-	}
31
+        /** @var \Phile\ServiceLocator\ErrorHandlerInterface $errorHandler */
32
+        $errorHandler = \Phile\Core\ServiceLocator::getService('Phile_ErrorHandler');
33
+        $errorHandler->handleException($e);
34
+    }
35 35
 }
Please login to merge, or discard this patch.
plugins/phile/testPlugin/config.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-	'A' => 'X',
5
-	'B' => 'B'
4
+    'A' => 'X',
5
+    'B' => 'B'
6 6
 ];
Please login to merge, or discard this patch.
plugins/phile/templateTwig/Classes/Template/Twig.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Template engine class
4
- */
3
+     * Template engine class
4
+     */
5 5
 namespace Phile\Plugin\Phile\TemplateTwig\Template;
6 6
 
7 7
 use Phile\Core\Event;
@@ -19,157 +19,157 @@  discard block
 block discarded – undo
19 19
  * @package Phile\Plugin\Phile\TemplateTwig\Template
20 20
  */
21 21
 class Twig implements TemplateInterface {
22
-	/**
23
-	 * @var array the complete phile config
24
-	 */
25
-	protected $settings;
26
-
27
-	/**
28
-	 * @var array the config for twig
29
-	 */
30
-	protected $config;
31
-
32
-	/**
33
-	 * @var Page the page model
34
-	 */
35
-	protected $page;
36
-
37
-	/**
38
-	 * the constructor
39
-	 *
40
-	 * @param array $config the configuration
41
-	 */
42
-	public function __construct($config = []) {
43
-		$this->config = $config;
44
-		$this->settings = Registry::get('Phile_Settings');
45
-	}
46
-
47
-	/**
48
-	 * method to set the current page
49
-	 *
50
-	 * @param Page $page the page model
51
-	 *
52
-	 * @return mixed|void
53
-	 */
54
-	public function setCurrentPage(Page $page) {
55
-		$this->page = $page;
56
-	}
57
-
58
-	/**
59
-	 * method to render the page/template
60
-	 *
61
-	 * @return mixed|string
62
-	 */
63
-	public function render() {
64
-		$engine = $this->getEngine();
65
-		$vars = $this->getTemplateVars();
66
-
67
-		Event::triggerEvent(
68
-			'template_engine_registered',
69
-			['engine' => &$engine, 'data' => &$vars]
70
-		);
71
-
72
-		return $this->_render($engine, $vars);
73
-	}
74
-
75
-	/**
76
-	 * wrapper to call the render engine
77
-	 *
78
-	 * @param $engine
79
-	 * @param $vars
80
-	 * @return mixed
81
-	 */
82
-	protected function _render($engine, $vars) {
83
-		try {
84
-			$template = $this->getTemplateFileName();
85
-		} catch (\RuntimeException $e) {
86
-			return $e->getMessage();
87
-		}
88
-		return $engine->render($template, $vars);
89
-	}
90
-
91
-	/**
92
-	 * get template engine
93
-	 *
94
-	 * @return \Twig_Environment
95
-	 */
96
-	protected function getEngine() {
97
-		$loader = new \Twig_Loader_Filesystem($this->getTemplatePath());
98
-		$twig = new \Twig_Environment($loader, $this->config);
99
-
100
-		// load the twig debug extension if required
101
-		if (!empty($this->config['debug'])) {
102
-			$twig->addExtension(new \Twig_Extension_Debug());
103
-		}
104
-		return $twig;
105
-	}
106
-
107
-	/**
108
-	 * get template file name
109
-	 *
110
-	 * @return string
111
-	 * @throws \RuntimeException
112
-	 */
113
-	protected function getTemplateFileName() {
114
-		$template = $this->page->getMeta()->get('template');
115
-		if (empty($template)) {
116
-			$template = 'index';
117
-		}
118
-		if (!empty($this->config['template-extension'])) {
119
-			$template .= '.' . $this->config['template-extension'];
120
-		}
121
-		$templatePath = $this->getTemplatePath($template);
122
-		if (!file_exists($templatePath)) {
123
-			throw new \RuntimeException(
124
-				"Template file '{$templatePath}' not found.",
125
-				1427990135
126
-			);
127
-		}
128
-		return $template;
129
-	}
130
-
131
-	/**
132
-	 * get file path to (sub-path) in theme-path
133
-	 *
134
-	 * @param string $sub
135
-	 * @return string
136
-	 */
137
-	protected function getTemplatePath($sub = '') {
138
-		$themePath = THEMES_DIR . $this->settings['theme'];
139
-		if (!empty($sub)) {
140
-			$themePath .= '/' . ltrim($sub, DIRECTORY_SEPARATOR);
141
-		}
142
-		return $themePath;
143
-	}
144
-
145
-	/**
146
-	 * get template vars
147
-	 *
148
-	 * @return array|mixed
149
-	 * @throws \Exception
150
-	 */
151
-	protected function getTemplateVars() {
152
-		$repository = new Repository($this->settings);
153
-		$defaults = [
154
-			'content' => $this->page->getContent(),
155
-			'meta' => $this->page->getMeta(),
156
-			'current_page' => $this->page,
157
-			'base_dir' => rtrim(ROOT_DIR, '/'),
158
-			'base_url' => $this->settings['base_url'],
159
-			'config' => $this->settings,
160
-			'content_dir' => CONTENT_DIR,
161
-			'content_url' => $this->settings['base_url'] . '/' . basename(CONTENT_DIR),
162
-			'pages' => $repository->findAll(),
163
-			'site_title' => $this->settings['site_title'],
164
-			'theme_dir' => THEMES_DIR . $this->settings['theme'],
165
-			'theme_url' => $this->settings['base_url'] . '/' . basename(THEMES_DIR) . '/' . $this->settings['theme'],
166
-		];
167
-
168
-		/** @var array $templateVars */
169
-		$templateVars = Registry::get('templateVars');
170
-		$templateVars += $defaults;
171
-
172
-		return $templateVars;
173
-	}
22
+    /**
23
+     * @var array the complete phile config
24
+     */
25
+    protected $settings;
26
+
27
+    /**
28
+     * @var array the config for twig
29
+     */
30
+    protected $config;
31
+
32
+    /**
33
+     * @var Page the page model
34
+     */
35
+    protected $page;
36
+
37
+    /**
38
+     * the constructor
39
+     *
40
+     * @param array $config the configuration
41
+     */
42
+    public function __construct($config = []) {
43
+        $this->config = $config;
44
+        $this->settings = Registry::get('Phile_Settings');
45
+    }
46
+
47
+    /**
48
+     * method to set the current page
49
+     *
50
+     * @param Page $page the page model
51
+     *
52
+     * @return mixed|void
53
+     */
54
+    public function setCurrentPage(Page $page) {
55
+        $this->page = $page;
56
+    }
57
+
58
+    /**
59
+     * method to render the page/template
60
+     *
61
+     * @return mixed|string
62
+     */
63
+    public function render() {
64
+        $engine = $this->getEngine();
65
+        $vars = $this->getTemplateVars();
66
+
67
+        Event::triggerEvent(
68
+            'template_engine_registered',
69
+            ['engine' => &$engine, 'data' => &$vars]
70
+        );
71
+
72
+        return $this->_render($engine, $vars);
73
+    }
74
+
75
+    /**
76
+     * wrapper to call the render engine
77
+     *
78
+     * @param $engine
79
+     * @param $vars
80
+     * @return mixed
81
+     */
82
+    protected function _render($engine, $vars) {
83
+        try {
84
+            $template = $this->getTemplateFileName();
85
+        } catch (\RuntimeException $e) {
86
+            return $e->getMessage();
87
+        }
88
+        return $engine->render($template, $vars);
89
+    }
90
+
91
+    /**
92
+     * get template engine
93
+     *
94
+     * @return \Twig_Environment
95
+     */
96
+    protected function getEngine() {
97
+        $loader = new \Twig_Loader_Filesystem($this->getTemplatePath());
98
+        $twig = new \Twig_Environment($loader, $this->config);
99
+
100
+        // load the twig debug extension if required
101
+        if (!empty($this->config['debug'])) {
102
+            $twig->addExtension(new \Twig_Extension_Debug());
103
+        }
104
+        return $twig;
105
+    }
106
+
107
+    /**
108
+     * get template file name
109
+     *
110
+     * @return string
111
+     * @throws \RuntimeException
112
+     */
113
+    protected function getTemplateFileName() {
114
+        $template = $this->page->getMeta()->get('template');
115
+        if (empty($template)) {
116
+            $template = 'index';
117
+        }
118
+        if (!empty($this->config['template-extension'])) {
119
+            $template .= '.' . $this->config['template-extension'];
120
+        }
121
+        $templatePath = $this->getTemplatePath($template);
122
+        if (!file_exists($templatePath)) {
123
+            throw new \RuntimeException(
124
+                "Template file '{$templatePath}' not found.",
125
+                1427990135
126
+            );
127
+        }
128
+        return $template;
129
+    }
130
+
131
+    /**
132
+     * get file path to (sub-path) in theme-path
133
+     *
134
+     * @param string $sub
135
+     * @return string
136
+     */
137
+    protected function getTemplatePath($sub = '') {
138
+        $themePath = THEMES_DIR . $this->settings['theme'];
139
+        if (!empty($sub)) {
140
+            $themePath .= '/' . ltrim($sub, DIRECTORY_SEPARATOR);
141
+        }
142
+        return $themePath;
143
+    }
144
+
145
+    /**
146
+     * get template vars
147
+     *
148
+     * @return array|mixed
149
+     * @throws \Exception
150
+     */
151
+    protected function getTemplateVars() {
152
+        $repository = new Repository($this->settings);
153
+        $defaults = [
154
+            'content' => $this->page->getContent(),
155
+            'meta' => $this->page->getMeta(),
156
+            'current_page' => $this->page,
157
+            'base_dir' => rtrim(ROOT_DIR, '/'),
158
+            'base_url' => $this->settings['base_url'],
159
+            'config' => $this->settings,
160
+            'content_dir' => CONTENT_DIR,
161
+            'content_url' => $this->settings['base_url'] . '/' . basename(CONTENT_DIR),
162
+            'pages' => $repository->findAll(),
163
+            'site_title' => $this->settings['site_title'],
164
+            'theme_dir' => THEMES_DIR . $this->settings['theme'],
165
+            'theme_url' => $this->settings['base_url'] . '/' . basename(THEMES_DIR) . '/' . $this->settings['theme'],
166
+        ];
167
+
168
+        /** @var array $templateVars */
169
+        $templateVars = Registry::get('templateVars');
170
+        $templateVars += $defaults;
171
+
172
+        return $templateVars;
173
+    }
174 174
 
175 175
 }
Please login to merge, or discard this patch.
plugins/phile/templateTwig/Classes/Plugin.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Template',
33
-			new Twig($this->settings));
34
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Template',
33
+            new Twig($this->settings));
34
+    }
35 35
 }
Please login to merge, or discard this patch.
plugins/phile/templateTwig/config.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /** config file */
3 3
 return array(
4
-	'template-extension' => 'html', // template file extension
5
-	'cache'      => false, // To enable Twig caching change this to CACHE_DIR
6
-	'autoescape' => false, // Autoescape Twig vars
7
-	'debug'      => false // Enable Twig debug
4
+    'template-extension' => 'html', // template file extension
5
+    'cache'      => false, // To enable Twig caching change this to CACHE_DIR
6
+    'autoescape' => false, // Autoescape Twig vars
7
+    'debug'      => false // Enable Twig debug
8 8
 );
Please login to merge, or discard this patch.
simpleFileDataPersistence/Classes/Persistence/SimpleFileDataPersistence.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * persistence implementation class
4
- */
3
+     * persistence implementation class
4
+     */
5 5
 namespace Phile\Plugin\Phile\SimpleFileDataPersistence\Persistence;
6 6
 
7 7
 use Phile\ServiceLocator\PersistenceInterface;
@@ -15,90 +15,90 @@  discard block
 block discarded – undo
15 15
  * @package Phile\Plugin\Phile\SimpleFileDataPersistence\Persistence
16 16
  */
17 17
 class SimpleFileDataPersistence implements PersistenceInterface {
18
-	/** @var string $dataDirectory the data storage directory */
19
-	protected $dataDirectory;
18
+    /** @var string $dataDirectory the data storage directory */
19
+    protected $dataDirectory;
20 20
 
21
-	/**
22
-	 * the constructor
23
-	 */
24
-	public function __construct() {
25
-		$this->dataDirectory = STORAGE_DIR;
26
-	}
21
+    /**
22
+     * the constructor
23
+     */
24
+    public function __construct() {
25
+        $this->dataDirectory = STORAGE_DIR;
26
+    }
27 27
 
28
-	/**
29
-	 * check if key exists
30
-	 *
31
-	 * @param $key
32
-	 *
33
-	 * @return bool|mixed
34
-	 */
35
-	public function has($key) {
36
-		return (file_exists($this->getStorageFile($key)));
37
-	}
28
+    /**
29
+     * check if key exists
30
+     *
31
+     * @param $key
32
+     *
33
+     * @return bool|mixed
34
+     */
35
+    public function has($key) {
36
+        return (file_exists($this->getStorageFile($key)));
37
+    }
38 38
 
39
-	/**
40
-	 * get value for given key
41
-	 *
42
-	 * @param $key
43
-	 *
44
-	 * @return mixed
45
-	 * @throws \Phile\Exception\AbstractException
46
-	 */
47
-	public function get($key) {
48
-		if (!$this->has($key)) {
49
-			throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!");
50
-		}
39
+    /**
40
+     * get value for given key
41
+     *
42
+     * @param $key
43
+     *
44
+     * @return mixed
45
+     * @throws \Phile\Exception\AbstractException
46
+     */
47
+    public function get($key) {
48
+        if (!$this->has($key)) {
49
+            throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!");
50
+        }
51 51
 
52
-		return unserialize(file_get_contents($this->getStorageFile($key)));
53
-	}
52
+        return unserialize(file_get_contents($this->getStorageFile($key)));
53
+    }
54 54
 
55
-	/**
56
-	 * set value for given key
57
-	 *
58
-	 * @param $key
59
-	 * @param $value
60
-	 *
61
-	 * @return mixed|void
62
-	 */
63
-	public function set($key, $value) {
64
-		file_put_contents($this->getStorageFile($key), serialize($value));
65
-	}
55
+    /**
56
+     * set value for given key
57
+     *
58
+     * @param $key
59
+     * @param $value
60
+     *
61
+     * @return mixed|void
62
+     */
63
+    public function set($key, $value) {
64
+        file_put_contents($this->getStorageFile($key), serialize($value));
65
+    }
66 66
 
67
-	/**
68
-	 * delte given key/index
69
-	 *
70
-	 * @param string $key
71
-	 * @param array  $options
72
-	 *
73
-	 * @return mixed|void
74
-	 * @throws \Phile\Exception\AbstractException
75
-	 */
76
-	public function delete($key, array $options = array()) {
77
-		if (!$this->has($key)) {
78
-			throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!");
79
-		}
80
-		unlink($this->getStorageFile($key));
81
-	}
67
+    /**
68
+     * delte given key/index
69
+     *
70
+     * @param string $key
71
+     * @param array  $options
72
+     *
73
+     * @return mixed|void
74
+     * @throws \Phile\Exception\AbstractException
75
+     */
76
+    public function delete($key, array $options = array()) {
77
+        if (!$this->has($key)) {
78
+            throw new \Phile\Exception\AbstractException("no data storage for key '{$key}' exists!");
79
+        }
80
+        unlink($this->getStorageFile($key));
81
+    }
82 82
 
83
-	/**
84
-	 * generate internal key
85
-	 *
86
-	 * @param $key
87
-	 *
88
-	 * @return string
89
-	 */
90
-	protected function getInternalKey($key) {
91
-		return md5($key);
92
-	}
83
+    /**
84
+     * generate internal key
85
+     *
86
+     * @param $key
87
+     *
88
+     * @return string
89
+     */
90
+    protected function getInternalKey($key) {
91
+        return md5($key);
92
+    }
93 93
 
94
-	/**
95
-	 * get storage filename
96
-	 *
97
-	 * @param $key
98
-	 *
99
-	 * @return string
100
-	 */
101
-	protected function getStorageFile($key) {
102
-		return $this->dataDirectory . $this->getInternalKey($key) . '.ds';
103
-	}
94
+    /**
95
+     * get storage filename
96
+     *
97
+     * @param $key
98
+     *
99
+     * @return string
100
+     */
101
+    protected function getStorageFile($key) {
102
+        return $this->dataDirectory . $this->getInternalKey($key) . '.ds';
103
+    }
104 104
 }
Please login to merge, or discard this patch.
plugins/phile/simpleFileDataPersistence/Classes/Plugin.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\SimpleFileDataPersistence;
6 6
 
7 7
 use Phile\Core\ServiceLocator;
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Data_Persistence',
33
-			new SimpleFileDataPersistence());
34
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Data_Persistence',
33
+            new SimpleFileDataPersistence());
34
+    }
35 35
 }
Please login to merge, or discard this patch.