Completed
Pull Request — master (#285)
by Frank
11:57
created
lib/Phile/Plugin/AbstractPlugin.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -19,109 +19,109 @@
 block discarded – undo
19 19
  */
20 20
 abstract class AbstractPlugin implements EventObserverInterface {
21 21
 
22
-	/** @var string plugin attributes */
23
-	protected $plugin = [];
24
-
25
-	 /** @var array subscribed Phile events ['eventName' => 'classMethodToCall'] */
26
-	protected $events = [];
27
-
28
-	/** @var array the plugin settings */
29
-	protected $settings = [];
30
-
31
-	/**
32
-	 * initialize plugin
33
-	 *
34
-	 * try to keep all initialization in one method to have a clean class
35
-	 * for the plugin-user
36
-	 *
37
-	 * @param string $pluginKey
38
-	 * @deprecated since 1.5.1 will be declared 'final'
39
-	 */
40
-	public function initializePlugin($pluginKey) {
41
-		/**
42
-		 * init $plugin property
43
-		 */
44
-		$this->plugin['key'] = $pluginKey;
45
-		list($vendor, $name) = explode('\\', $this->plugin['key']);
46
-		$DS = DIRECTORY_SEPARATOR;
47
-		$this->plugin['dir'] = PLUGINS_DIR . $vendor . $DS . $name . $DS;
48
-
49
-		/**
50
-		 * init events
51
-		 */
52
-		foreach ($this->events as $event => $method) {
53
-			Event::registerEvent($event, $this);
54
-		}
55
-
56
-		/**
57
-		 * init plugin settings
58
-		 */
59
-		$defaults = Utility::load($this->getPluginPath('config.php'));
60
-		if (empty($defaults) || !is_array($defaults)) {
61
-			$defaults = [];
62
-		}
63
-
64
-		$globals = Registry::get('Phile_Settings');
65
-		if (!isset($globals['plugins'][$pluginKey])) {
66
-			$globals['plugins'][$pluginKey] = [];
67
-		}
68
-
69
-		// settings precedence: global > default > class
70
-		$this->settings = array_replace_recursive(
71
-			$this->settings,
72
-			$defaults,
73
-			$globals['plugins'][$pluginKey]
74
-		);
75
-
76
-		// backwards compatibility to Phile 1.4
77
-		$this->injectSettings($this->settings);
78
-
79
-		$globals['plugins'][$pluginKey]['settings'] = $this->settings;
80
-		Registry::set('Phile_Settings', $globals);
81
-
82
-	}
83
-
84
-	/**
85
-	 * inject settings
86
-	 *
87
-	 * backwards compatibility to Phile 1.4
88
-	 *
89
-	 * @param array $settings
90
-	 * @deprecated since 1.5.1 will be removed
91
-	 */
92
-	public function injectSettings(array $settings = null) {
93
-	}
94
-
95
-	/**
96
-	 * implements EventObserverInterface
97
-	 *
98
-	 * @param string $eventKey
99
-	 * @param null $data
100
-	 * @return void
101
-	 */
102
-	public function on($eventKey, $data = null) {
103
-		if (!isset($this->events[$eventKey])) {
104
-			return;
105
-		}
106
-		$method = $this->events[$eventKey];
107
-		if (!is_callable([$this, $method])) {
108
-			$class = get_class($this);
109
-			throw new \RuntimeException(
110
-				"Event $eventKey can't invoke $class::$method(). Not callable.",
111
-				1428564865
112
-			);
113
-		}
114
-		$this->{$this->events[$eventKey]}($data);
115
-	}
116
-
117
-	/**
118
-	 * get file path to plugin root (trailing slash) or to a sub-item
119
-	 *
120
-	 * @param string $subPath
121
-	 * @return null|string null if item does not exist
122
-	 */
123
-	protected function getPluginPath($subPath = '') {
124
-		return $this->plugin['dir'] . ltrim($subPath, DIRECTORY_SEPARATOR);
125
-	}
22
+    /** @var string plugin attributes */
23
+    protected $plugin = [];
24
+
25
+        /** @var array subscribed Phile events ['eventName' => 'classMethodToCall'] */
26
+    protected $events = [];
27
+
28
+    /** @var array the plugin settings */
29
+    protected $settings = [];
30
+
31
+    /**
32
+     * initialize plugin
33
+     *
34
+     * try to keep all initialization in one method to have a clean class
35
+     * for the plugin-user
36
+     *
37
+     * @param string $pluginKey
38
+     * @deprecated since 1.5.1 will be declared 'final'
39
+     */
40
+    public function initializePlugin($pluginKey) {
41
+        /**
42
+         * init $plugin property
43
+         */
44
+        $this->plugin['key'] = $pluginKey;
45
+        list($vendor, $name) = explode('\\', $this->plugin['key']);
46
+        $DS = DIRECTORY_SEPARATOR;
47
+        $this->plugin['dir'] = PLUGINS_DIR . $vendor . $DS . $name . $DS;
48
+
49
+        /**
50
+         * init events
51
+         */
52
+        foreach ($this->events as $event => $method) {
53
+            Event::registerEvent($event, $this);
54
+        }
55
+
56
+        /**
57
+         * init plugin settings
58
+         */
59
+        $defaults = Utility::load($this->getPluginPath('config.php'));
60
+        if (empty($defaults) || !is_array($defaults)) {
61
+            $defaults = [];
62
+        }
63
+
64
+        $globals = Registry::get('Phile_Settings');
65
+        if (!isset($globals['plugins'][$pluginKey])) {
66
+            $globals['plugins'][$pluginKey] = [];
67
+        }
68
+
69
+        // settings precedence: global > default > class
70
+        $this->settings = array_replace_recursive(
71
+            $this->settings,
72
+            $defaults,
73
+            $globals['plugins'][$pluginKey]
74
+        );
75
+
76
+        // backwards compatibility to Phile 1.4
77
+        $this->injectSettings($this->settings);
78
+
79
+        $globals['plugins'][$pluginKey]['settings'] = $this->settings;
80
+        Registry::set('Phile_Settings', $globals);
81
+
82
+    }
83
+
84
+    /**
85
+     * inject settings
86
+     *
87
+     * backwards compatibility to Phile 1.4
88
+     *
89
+     * @param array $settings
90
+     * @deprecated since 1.5.1 will be removed
91
+     */
92
+    public function injectSettings(array $settings = null) {
93
+    }
94
+
95
+    /**
96
+     * implements EventObserverInterface
97
+     *
98
+     * @param string $eventKey
99
+     * @param null $data
100
+     * @return void
101
+     */
102
+    public function on($eventKey, $data = null) {
103
+        if (!isset($this->events[$eventKey])) {
104
+            return;
105
+        }
106
+        $method = $this->events[$eventKey];
107
+        if (!is_callable([$this, $method])) {
108
+            $class = get_class($this);
109
+            throw new \RuntimeException(
110
+                "Event $eventKey can't invoke $class::$method(). Not callable.",
111
+                1428564865
112
+            );
113
+        }
114
+        $this->{$this->events[$eventKey]}($data);
115
+    }
116
+
117
+    /**
118
+     * get file path to plugin root (trailing slash) or to a sub-item
119
+     *
120
+     * @param string $subPath
121
+     * @return null|string null if item does not exist
122
+     */
123
+    protected function getPluginPath($subPath = '') {
124
+        return $this->plugin['dir'] . ltrim($subPath, DIRECTORY_SEPARATOR);
125
+    }
126 126
 
127 127
 }
Please login to merge, or discard this patch.
lib/Phile/Core.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -18,165 +18,165 @@
 block discarded – undo
18 18
  * @package Phile
19 19
  */
20 20
 class Core {
21
-	/**
22
-	 * @var array the settings array
23
-	 */
24
-	protected $settings;
25
-
26
-	/**
27
-	 * @var array the loaded plugins
28
-	 */
29
-	protected $plugins;
30
-
31
-	/**
32
-	 * @var \Phile\Repository\Page the page repository
33
-	 */
34
-	protected $pageRepository;
35
-
36
-	/**
37
-	 * @var null|\Phile\Model\Page the page model
38
-	 */
39
-	protected $page;
40
-
41
-	/**
42
-	 * @var string the output (rendered page)
43
-	 */
44
-	protected $output;
45
-
46
-	/**
47
-	 * @var \Phile\Core\Response the response the core send
48
-	 */
49
-	protected $response;
50
-
51
-	/**
52
-	 * @var Router
53
-	 */
54
-	protected $router;
55
-
56
-	/**
57
-	 * The constructor carries out all the processing in Phile.
58
-	 * Does URL routing, Markdown processing and Twig processing.
59
-	 *
60
-	 * @param Router $router
61
-	 * @param Response $response
62
-	 * @throws \Exception
63
-	 */
64
-	public function __construct(Router $router, Response $response) {
65
-		$this->initializeErrorHandling();
66
-		$this->initialize($router, $response);
67
-		$this->checkSetup();
68
-		$this->initializeCurrentPage();
69
-		$this->initializeTemplate();
70
-	}
71
-
72
-	/**
73
-	 * return the page
74
-	 *
75
-	 * @return string
76
-	 */
77
-	public function render() {
78
-		$this->response->send();
79
-	}
80
-
81
-	protected function initialize(Router $router, Response $response) {
82
-		$this->settings = Registry::get('Phile_Settings');
83
-		$this->pageRepository = new Repository();
84
-		$this->router = $router;
85
-		$this->response = $response;
86
-		$this->response->setCharset($this->settings['charset']);
87
-
88
-		Event::triggerEvent('after_init_core', ['response' => $this->response]);
89
-	}
90
-
91
-	/**
92
-	 * initialize the current page
93
-	 */
94
-	protected function initializeCurrentPage() {
95
-		$pageId = $this->router->getCurrentUrl();
96
-
97
-		Event::triggerEvent('request_uri', ['uri' => $pageId]);
98
-
99
-		$page = $this->pageRepository->findByPath($pageId);
100
-		$found = $page instanceof Page;
101
-
102
-		if ($found && $pageId !== $page->getPageId()) {
103
-			$url = $this->router->urlForPage($page->getPageId());
104
-			$this->response->redirect($url, 301);
105
-		}
106
-
107
-		if (!$found) {
108
-			$this->response->setStatusCode(404);
109
-			$page = $this->pageRepository->findByPath('404');
110
-			Event::triggerEvent('after_404');
111
-		}
112
-
113
-		Event::triggerEvent('after_resolve_page', ['pageId' => $pageId, 'page' => &$page]);
114
-
115
-		$this->page = $page;
116
-	}
117
-
118
-	/**
119
-	 * initialize error handling
120
-	 */
121
-	protected function initializeErrorHandling() {
122
-		if (ServiceLocator::hasService('Phile_ErrorHandler')) {
123
-			$errorHandler = ServiceLocator::getService('Phile_ErrorHandler');
124
-			set_error_handler([$errorHandler, 'handleError']);
125
-			register_shutdown_function([$errorHandler, 'handleShutdown']);
126
-			ini_set('display_errors', $this->settings['display_errors']);
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * check the setup
132
-	 */
133
-	protected function checkSetup() {
134
-		/**
135
-		 * @triggerEvent before_setup_check this event is triggered before the setup check
136
-		 */
137
-		Event::triggerEvent('before_setup_check');
138
-
139
-		if (!Registry::isRegistered('templateVars')) {
140
-			Registry::set('templateVars', []);
141
-		}
142
-
143
-		Event::triggerEvent('setup_check');
144
-
145
-		/**
146
-		 * @triggerEvent after_setup_check this event is triggered after the setup check
147
-		 */
148
-		Event::triggerEvent('after_setup_check');
149
-	}
150
-
151
-	/**
152
-	 * initialize template engine
153
-	 */
154
-	protected function initializeTemplate() {
155
-		/**
156
-		 * @triggerEvent before_init_template this event is triggered before the template engine is init
157
-		 */
158
-		Event::triggerEvent('before_init_template');
159
-
160
-		$templateEngine = ServiceLocator::getService('Phile_Template');
161
-
162
-		/**
163
-		 * @triggerEvent before_render_template this event is triggered before the template is rendered
164
-		 *
165
-		 * @param \Phile\ServiceLocator\TemplateInterface the template engine
166
-		 */
167
-		Event::triggerEvent('before_render_template', array('templateEngine' => &$templateEngine));
168
-
169
-		$templateEngine->setCurrentPage($this->page);
170
-		$output = $templateEngine->render();
171
-
172
-		/**
173
-		 * @triggerEvent after_render_template this event is triggered after the template is rendered
174
-		 *
175
-		 * @param \Phile\ServiceLocator\TemplateInterface the    template engine
176
-		 * @param                                         string the generated ouput
177
-		 */
178
-		Event::triggerEvent('after_render_template', array('templateEngine' => &$templateEngine, 'output' => &$output));
179
-		$this->response->setBody($output);
180
-	}
21
+    /**
22
+     * @var array the settings array
23
+     */
24
+    protected $settings;
25
+
26
+    /**
27
+     * @var array the loaded plugins
28
+     */
29
+    protected $plugins;
30
+
31
+    /**
32
+     * @var \Phile\Repository\Page the page repository
33
+     */
34
+    protected $pageRepository;
35
+
36
+    /**
37
+     * @var null|\Phile\Model\Page the page model
38
+     */
39
+    protected $page;
40
+
41
+    /**
42
+     * @var string the output (rendered page)
43
+     */
44
+    protected $output;
45
+
46
+    /**
47
+     * @var \Phile\Core\Response the response the core send
48
+     */
49
+    protected $response;
50
+
51
+    /**
52
+     * @var Router
53
+     */
54
+    protected $router;
55
+
56
+    /**
57
+     * The constructor carries out all the processing in Phile.
58
+     * Does URL routing, Markdown processing and Twig processing.
59
+     *
60
+     * @param Router $router
61
+     * @param Response $response
62
+     * @throws \Exception
63
+     */
64
+    public function __construct(Router $router, Response $response) {
65
+        $this->initializeErrorHandling();
66
+        $this->initialize($router, $response);
67
+        $this->checkSetup();
68
+        $this->initializeCurrentPage();
69
+        $this->initializeTemplate();
70
+    }
71
+
72
+    /**
73
+     * return the page
74
+     *
75
+     * @return string
76
+     */
77
+    public function render() {
78
+        $this->response->send();
79
+    }
80
+
81
+    protected function initialize(Router $router, Response $response) {
82
+        $this->settings = Registry::get('Phile_Settings');
83
+        $this->pageRepository = new Repository();
84
+        $this->router = $router;
85
+        $this->response = $response;
86
+        $this->response->setCharset($this->settings['charset']);
87
+
88
+        Event::triggerEvent('after_init_core', ['response' => $this->response]);
89
+    }
90
+
91
+    /**
92
+     * initialize the current page
93
+     */
94
+    protected function initializeCurrentPage() {
95
+        $pageId = $this->router->getCurrentUrl();
96
+
97
+        Event::triggerEvent('request_uri', ['uri' => $pageId]);
98
+
99
+        $page = $this->pageRepository->findByPath($pageId);
100
+        $found = $page instanceof Page;
101
+
102
+        if ($found && $pageId !== $page->getPageId()) {
103
+            $url = $this->router->urlForPage($page->getPageId());
104
+            $this->response->redirect($url, 301);
105
+        }
106
+
107
+        if (!$found) {
108
+            $this->response->setStatusCode(404);
109
+            $page = $this->pageRepository->findByPath('404');
110
+            Event::triggerEvent('after_404');
111
+        }
112
+
113
+        Event::triggerEvent('after_resolve_page', ['pageId' => $pageId, 'page' => &$page]);
114
+
115
+        $this->page = $page;
116
+    }
117
+
118
+    /**
119
+     * initialize error handling
120
+     */
121
+    protected function initializeErrorHandling() {
122
+        if (ServiceLocator::hasService('Phile_ErrorHandler')) {
123
+            $errorHandler = ServiceLocator::getService('Phile_ErrorHandler');
124
+            set_error_handler([$errorHandler, 'handleError']);
125
+            register_shutdown_function([$errorHandler, 'handleShutdown']);
126
+            ini_set('display_errors', $this->settings['display_errors']);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * check the setup
132
+     */
133
+    protected function checkSetup() {
134
+        /**
135
+         * @triggerEvent before_setup_check this event is triggered before the setup check
136
+         */
137
+        Event::triggerEvent('before_setup_check');
138
+
139
+        if (!Registry::isRegistered('templateVars')) {
140
+            Registry::set('templateVars', []);
141
+        }
142
+
143
+        Event::triggerEvent('setup_check');
144
+
145
+        /**
146
+         * @triggerEvent after_setup_check this event is triggered after the setup check
147
+         */
148
+        Event::triggerEvent('after_setup_check');
149
+    }
150
+
151
+    /**
152
+     * initialize template engine
153
+     */
154
+    protected function initializeTemplate() {
155
+        /**
156
+         * @triggerEvent before_init_template this event is triggered before the template engine is init
157
+         */
158
+        Event::triggerEvent('before_init_template');
159
+
160
+        $templateEngine = ServiceLocator::getService('Phile_Template');
161
+
162
+        /**
163
+         * @triggerEvent before_render_template this event is triggered before the template is rendered
164
+         *
165
+         * @param \Phile\ServiceLocator\TemplateInterface the template engine
166
+         */
167
+        Event::triggerEvent('before_render_template', array('templateEngine' => &$templateEngine));
168
+
169
+        $templateEngine->setCurrentPage($this->page);
170
+        $output = $templateEngine->render();
171
+
172
+        /**
173
+         * @triggerEvent after_render_template this event is triggered after the template is rendered
174
+         *
175
+         * @param \Phile\ServiceLocator\TemplateInterface the    template engine
176
+         * @param                                         string the generated ouput
177
+         */
178
+        Event::triggerEvent('after_render_template', array('templateEngine' => &$templateEngine, 'output' => &$output));
179
+        $this->response->setBody($output);
180
+    }
181 181
 
182 182
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/ParserInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface ParserInterface {
15
-	/**
16
-	 * parse data
17
-	 *
18
-	 * @param $data
19
-	 *
20
-	 * @return mixed
21
-	 */
22
-	public function parse($data);
15
+    /**
16
+     * parse data
17
+     *
18
+     * @param $data
19
+     *
20
+     * @return mixed
21
+     */
22
+    public function parse($data);
23 23
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/PersistenceInterface.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Persistence ServiceLocator interface
4
- */
3
+     * The Persistence ServiceLocator interface
4
+     */
5 5
 namespace Phile\ServiceLocator;
6 6
 
7 7
 /**
@@ -12,40 +12,40 @@  discard block
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface PersistenceInterface {
15
-	/**
16
-	 * check if an entry exists for given key
17
-	 *
18
-	 * @param $key
19
-	 *
20
-	 * @return mixed
21
-	 */
22
-	public function has($key);
15
+    /**
16
+     * check if an entry exists for given key
17
+     *
18
+     * @param $key
19
+     *
20
+     * @return mixed
21
+     */
22
+    public function has($key);
23 23
 
24
-	/**
25
-	 * get the entry by given key
26
-	 *
27
-	 * @param $key
28
-	 *
29
-	 * @return mixed
30
-	 */
31
-	public function get($key);
24
+    /**
25
+     * get the entry by given key
26
+     *
27
+     * @param $key
28
+     *
29
+     * @return mixed
30
+     */
31
+    public function get($key);
32 32
 
33
-	/**
34
-	 * set the value for given key
35
-	 *
36
-	 * @param $key
37
-	 * @param $value
38
-	 *
39
-	 * @return mixed
40
-	 */
41
-	public function set($key, $value);
33
+    /**
34
+     * set the value for given key
35
+     *
36
+     * @param $key
37
+     * @param $value
38
+     *
39
+     * @return mixed
40
+     */
41
+    public function set($key, $value);
42 42
 
43
-	/**
44
-	 * delete the entry by given key
45
-	 *
46
-	 * @param $key
47
-	 *
48
-	 * @return mixed
49
-	 */
50
-	public function delete($key);
43
+    /**
44
+     * delete the entry by given key
45
+     *
46
+     * @param $key
47
+     *
48
+     * @return mixed
49
+     */
50
+    public function delete($key);
51 51
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/TemplateInterface.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The TemplateInterface
4
- */
3
+     * The TemplateInterface
4
+     */
5 5
 namespace Phile\ServiceLocator;
6 6
 
7 7
 /**
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface TemplateInterface {
15
-	/**
16
-	 * render the template
17
-	 *
18
-	 * @return mixed
19
-	 */
20
-	public function render();
15
+    /**
16
+     * render the template
17
+     *
18
+     * @return mixed
19
+     */
20
+    public function render();
21 21
 
22
-	/**
23
-	 * set current page
24
-	 *
25
-	 * @param \Phile\Model\Page $page
26
-	 *
27
-	 * @return mixed
28
-	 */
29
-	public function setCurrentPage(\Phile\Model\Page $page);
22
+    /**
23
+     * set current page
24
+     *
25
+     * @param \Phile\Model\Page $page
26
+     *
27
+     * @return mixed
28
+     */
29
+    public function setCurrentPage(\Phile\Model\Page $page);
30 30
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/CacheInterface.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Interface for a service locator
4
- */
3
+     * Interface for a service locator
4
+     */
5 5
 namespace Phile\ServiceLocator;
6 6
 
7 7
 /**
@@ -12,48 +12,48 @@  discard block
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface CacheInterface {
15
-	/**
16
-	 * check if an entry with this key exists
17
-	 *
18
-	 * @param $key
19
-	 *
20
-	 * @return mixed
21
-	 */
22
-	public function has($key);
15
+    /**
16
+     * check if an entry with this key exists
17
+     *
18
+     * @param $key
19
+     *
20
+     * @return mixed
21
+     */
22
+    public function has($key);
23 23
 
24
-	/**
25
-	 * get the entry by given key
26
-	 *
27
-	 * @param $key
28
-	 *
29
-	 * @return mixed
30
-	 */
31
-	public function get($key);
24
+    /**
25
+     * get the entry by given key
26
+     *
27
+     * @param $key
28
+     *
29
+     * @return mixed
30
+     */
31
+    public function get($key);
32 32
 
33
-	/**
34
-	 * set the entry to the given key
35
-	 *
36
-	 * @param       $key
37
-	 * @param       $value
38
-	 * @param int   $time
39
-	 * @param array $options
40
-	 *
41
-	 * @return mixed
42
-	 */
43
-	public function set($key, $value, $time = 300, array $options = array());
33
+    /**
34
+     * set the entry to the given key
35
+     *
36
+     * @param       $key
37
+     * @param       $value
38
+     * @param int   $time
39
+     * @param array $options
40
+     *
41
+     * @return mixed
42
+     */
43
+    public function set($key, $value, $time = 300, array $options = array());
44 44
 
45
-	/**
46
-	 * delete the entry by given key
47
-	 *
48
-	 * @param       $key
49
-	 * @param array $options
50
-	 *
51
-	 * @return mixed
52
-	 */
53
-	public function delete($key, array $options = array());
45
+    /**
46
+     * delete the entry by given key
47
+     *
48
+     * @param       $key
49
+     * @param array $options
50
+     *
51
+     * @return mixed
52
+     */
53
+    public function delete($key, array $options = array());
54 54
 
55
-	/**
56
-	 * clean complete cache and delete all cached entries
57
-	 */
58
-	public function clean();
55
+    /**
56
+     * clean complete cache and delete all cached entries
57
+     */
58
+    public function clean();
59 59
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/MetaInterface.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * ServiceLocator MetaParser interface
4
- */
3
+     * ServiceLocator MetaParser interface
4
+     */
5 5
 namespace Phile\ServiceLocator;
6 6
 
7 7
 /**
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface MetaInterface {
15
-	/**
16
-	 * parse the content
17
-	 *
18
-	 * @param $rawData
19
-	 *
20
-	 * @return array with key/value store
21
-	 */
22
-	public function parse($rawData);
15
+    /**
16
+     * parse the content
17
+     *
18
+     * @param $rawData
19
+     *
20
+     * @return array with key/value store
21
+     */
22
+    public function parse($rawData);
23 23
 }
Please login to merge, or discard this patch.
lib/Phile/ServiceLocator/ErrorHandlerInterface.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The ErrorHandlerInterface
4
- */
3
+     * The ErrorHandlerInterface
4
+     */
5 5
 namespace Phile\ServiceLocator;
6 6
 
7 7
 /**
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
  * @package Phile\ServiceLocator
13 13
  */
14 14
 interface ErrorHandlerInterface {
15
-	/**
16
-	 * handle the error
17
-	 *
18
-	 * @param int    $errno
19
-	 * @param string $errstr
20
-	 * @param string $errfile
21
-	 * @param int    $errline
22
-	 * @param array  $errcontext
23
-	 *
24
-	 * @return boolean
25
-	 */
26
-	public function handleError($errno, $errstr, $errfile, $errline, array $errcontext);
15
+    /**
16
+     * handle the error
17
+     *
18
+     * @param int    $errno
19
+     * @param string $errstr
20
+     * @param string $errfile
21
+     * @param int    $errline
22
+     * @param array  $errcontext
23
+     *
24
+     * @return boolean
25
+     */
26
+    public function handleError($errno, $errstr, $errfile, $errline, array $errcontext);
27 27
 
28
-	/**
29
-	 * handle all exceptions
30
-	 *
31
-	 * @param \Exception $exception
32
-	 *
33
-	 * @return mixed
34
-	 */
35
-	public function handleException(\Exception $exception);
28
+    /**
29
+     * handle all exceptions
30
+     *
31
+     * @param \Exception $exception
32
+     *
33
+     * @return mixed
34
+     */
35
+    public function handleException(\Exception $exception);
36 36
 }
Please login to merge, or discard this patch.
lib/Phile/Model/Page.php 1 patch
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The page model
4
- */
3
+     * The page model
4
+     */
5 5
 namespace Phile\Model;
6 6
 
7 7
 use Phile\Core\Router;
@@ -17,237 +17,237 @@  discard block
 block discarded – undo
17 17
  * @package Phile\Model
18 18
  */
19 19
 class Page {
20
-	/**
21
-	 * @var \Phile\Model\Meta the meta model
22
-	 */
23
-	protected $meta;
24
-
25
-	/**
26
-	 * @var string the content
27
-	 */
28
-	protected $content;
29
-
30
-	/**
31
-	 * @var string the path to the original file
32
-	 */
33
-	protected $filePath;
34
-
35
-	/**
36
-	 * @var string the raw file
37
-	 */
38
-	protected $rawData;
39
-
40
-	/**
41
-	 * @var \Phile\ServiceLocator\ParserInterface the parser
42
-	 */
43
-	protected $parser;
44
-
45
-	/**
46
-	 * @var string the pageId of the page
47
-	 */
48
-	protected $pageId;
49
-
50
-	/**
51
-	 * @var \Phile\Model\Page the previous page if one exist
52
-	 */
53
-	protected $previousPage;
54
-
55
-	/**
56
-	 * @var \Phile\Model\Page the next page if one exist
57
-	 */
58
-	protected $nextPage;
59
-
60
-	/**
61
-	 * @var string The content folder, as passed to the class constructor when initiating the object.
62
-	 */
63
-	protected $contentFolder = CONTENT_DIR;
64
-
65
-	/**
66
-	 * the constructor
67
-	 *
68
-	 * @param        $filePath
69
-	 * @param string $folder
70
-	 */
71
-	public function __construct($filePath, $folder = CONTENT_DIR) {
72
-		$this->contentFolder = $folder;
73
-		$this->setFilePath($filePath);
74
-
75
-		/**
76
-		 * @triggerEvent before_load_content this event is triggered before the content is loaded
77
-		 *
78
-		 * @param            string filePath the path to the file
79
-		 * @param \Phile\Model\Page page     the page model
80
-		 */
81
-		Event::triggerEvent('before_load_content', array('filePath' => &$this->filePath, 'page' => &$this));
82
-		if (file_exists($this->filePath)) {
83
-			$this->rawData = file_get_contents($this->filePath);
84
-			$this->parseRawData();
85
-		}
86
-		/**
87
-		 * @triggerEvent after_load_content this event is triggered after the content is loaded
88
-		 *
89
-		 * @param            string filePath the path to the file
90
-		 * @param            string rawData  the raw data
91
-		 * @param \Phile\Model\Page page     the page model
92
-		 */
93
-		Event::triggerEvent('after_load_content', array('filePath' => &$this->filePath, 'rawData' => $this->rawData, 'page' => &$this));
94
-
95
-		$this->parser = ServiceLocator::getService('Phile_Parser');
96
-	}
97
-
98
-	/**
99
-	 * method to get content of page, this method returned the parsed content
100
-	 *
101
-	 * @return mixed
102
-	 */
103
-	public function getContent() {
104
-		/**
105
-		 * @triggerEvent before_parse_content this event is triggered before the content is parsed
106
-		 *
107
-		 * @param            string content the raw data
108
-		 * @param \Phile\Model\Page page    the page model
109
-		 */
110
-		Event::triggerEvent('before_parse_content', array('content' => $this->content, 'page' => &$this));
111
-		$content = $this->parser->parse($this->content);
112
-		/**
113
-		 * @triggerEvent after_parse_content this event is triggered after the content is parsed
114
-		 *
115
-		 * @param            string content the parsed content
116
-		 * @param \Phile\Model\Page page    the page model
117
-		 */
118
-		Event::triggerEvent('after_parse_content', array('content' => &$content, 'page' => &$this));
119
-
120
-		return $content;
121
-	}
122
-
123
-	/**
124
-	 * set content of page
125
-	 *
126
-	 * @param $content
127
-	 */
128
-	public function setContent($content) {
129
-		$this->content = $content;
130
-	}
131
-
132
-	/**
133
-	 * get raw (un-parsed) page content
134
-	 *
135
-	 * @return string
136
-	 */
137
-	public function getRawContent() {
138
-		return $this->content;
139
-	}
140
-
141
-	/**
142
-	 * get the meta model
143
-	 *
144
-	 * @return Meta
145
-	 */
146
-	public function getMeta() {
147
-		return $this->meta;
148
-	}
149
-
150
-	/**
151
-	 * parse the raw content
152
-	 */
153
-	protected function parseRawData() {
154
-		$this->meta = new Meta($this->rawData);
155
-		// Remove only the optional, leading meta-block comment
156
-		$rawData = trim($this->rawData);
157
-		if (strncmp('<!--', $rawData, 4) === 0) {
158
-			// leading meta-block comment uses the <!-- --> style
159
-			$this->content = substr($rawData, max(4, strpos($rawData, '-->') + 3));
160
-		} elseif (strncmp('/*', $rawData, 2) === 0) {
161
-			// leading meta-block comment uses the /* */ style
162
-			$this->content = substr($rawData, strpos($rawData, '*/') + 2);
163
-		} else {
164
-			// no leading meta-block comment
165
-			$this->content = $rawData;
166
-		}
167
-	}
168
-
169
-	/**
170
-	 * get the title of page from meta information
171
-	 *
172
-	 * @return string|null
173
-	 */
174
-	public function getTitle() {
175
-		return $this->getMeta()->get('title');
176
-	}
177
-
178
-	/**
179
-	 * get Phile $pageId
180
-	 *
181
-	 * @param string $filePath
182
-	 * @return string
183
-	 */
184
-	protected function buildPageId($filePath) {
185
-		$pageId = str_replace($this->contentFolder, '', $filePath);
186
-		$pageId = str_replace(CONTENT_EXT, '', $pageId);
187
-		$pageId = str_replace(DIRECTORY_SEPARATOR, '/', $pageId);
188
-		$pageId = ltrim($pageId, '/');
189
-		$pageId = preg_replace('/(?<=^|\/)index$/', '', $pageId);
190
-		return $pageId;
191
-	}
192
-
193
-	/**
194
-	 * get the url of page
195
-	 *
196
-	 * @return string
197
-	 */
198
-	public function getUrl() {
199
-		return (new Router)->urlForPage($this->pageId, false);
200
-	}
201
-
202
-	/**
203
-	 * set the filepath of the page
204
-	 *
205
-	 * @param string $filePath
206
-	 */
207
-	public function setFilePath($filePath) {
208
-		$this->filePath = $filePath;
209
-		$this->pageId = $this->buildPageId($this->filePath);
210
-	}
211
-
212
-	/**
213
-	 * get the filepath of the page
214
-	 *
215
-	 * @return string
216
-	 */
217
-	public function getFilePath() {
218
-		return $this->filePath;
219
-	}
220
-
221
-	/**
222
-	 * get the folder name
223
-	 *
224
-	 * @return string
225
-	 */
226
-	public function getFolder() {
227
-		return basename(dirname($this->getFilePath()));
228
-	}
229
-
230
-	public function getPageId() {
231
-		return $this->pageId;
232
-	}
233
-
234
-	/**
235
-	 * get the previous page if one exist
236
-	 *
237
-	 * @return null|\Phile\Model\Page
238
-	 */
239
-	public function getPreviousPage() {
240
-		$pageRepository = new \Phile\Repository\Page();
241
-		return $pageRepository->getPageOffset($this, -1);
242
-	}
243
-
244
-	/**
245
-	 * get the next page if one exist
246
-	 *
247
-	 * @return null|\Phile\Model\Page
248
-	 */
249
-	public function getNextPage() {
250
-		$pageRepository = new \Phile\Repository\Page();
251
-		return $pageRepository->getPageOffset($this, 1);
252
-	}
20
+    /**
21
+     * @var \Phile\Model\Meta the meta model
22
+     */
23
+    protected $meta;
24
+
25
+    /**
26
+     * @var string the content
27
+     */
28
+    protected $content;
29
+
30
+    /**
31
+     * @var string the path to the original file
32
+     */
33
+    protected $filePath;
34
+
35
+    /**
36
+     * @var string the raw file
37
+     */
38
+    protected $rawData;
39
+
40
+    /**
41
+     * @var \Phile\ServiceLocator\ParserInterface the parser
42
+     */
43
+    protected $parser;
44
+
45
+    /**
46
+     * @var string the pageId of the page
47
+     */
48
+    protected $pageId;
49
+
50
+    /**
51
+     * @var \Phile\Model\Page the previous page if one exist
52
+     */
53
+    protected $previousPage;
54
+
55
+    /**
56
+     * @var \Phile\Model\Page the next page if one exist
57
+     */
58
+    protected $nextPage;
59
+
60
+    /**
61
+     * @var string The content folder, as passed to the class constructor when initiating the object.
62
+     */
63
+    protected $contentFolder = CONTENT_DIR;
64
+
65
+    /**
66
+     * the constructor
67
+     *
68
+     * @param        $filePath
69
+     * @param string $folder
70
+     */
71
+    public function __construct($filePath, $folder = CONTENT_DIR) {
72
+        $this->contentFolder = $folder;
73
+        $this->setFilePath($filePath);
74
+
75
+        /**
76
+         * @triggerEvent before_load_content this event is triggered before the content is loaded
77
+         *
78
+         * @param            string filePath the path to the file
79
+         * @param \Phile\Model\Page page     the page model
80
+         */
81
+        Event::triggerEvent('before_load_content', array('filePath' => &$this->filePath, 'page' => &$this));
82
+        if (file_exists($this->filePath)) {
83
+            $this->rawData = file_get_contents($this->filePath);
84
+            $this->parseRawData();
85
+        }
86
+        /**
87
+         * @triggerEvent after_load_content this event is triggered after the content is loaded
88
+         *
89
+         * @param            string filePath the path to the file
90
+         * @param            string rawData  the raw data
91
+         * @param \Phile\Model\Page page     the page model
92
+         */
93
+        Event::triggerEvent('after_load_content', array('filePath' => &$this->filePath, 'rawData' => $this->rawData, 'page' => &$this));
94
+
95
+        $this->parser = ServiceLocator::getService('Phile_Parser');
96
+    }
97
+
98
+    /**
99
+     * method to get content of page, this method returned the parsed content
100
+     *
101
+     * @return mixed
102
+     */
103
+    public function getContent() {
104
+        /**
105
+         * @triggerEvent before_parse_content this event is triggered before the content is parsed
106
+         *
107
+         * @param            string content the raw data
108
+         * @param \Phile\Model\Page page    the page model
109
+         */
110
+        Event::triggerEvent('before_parse_content', array('content' => $this->content, 'page' => &$this));
111
+        $content = $this->parser->parse($this->content);
112
+        /**
113
+         * @triggerEvent after_parse_content this event is triggered after the content is parsed
114
+         *
115
+         * @param            string content the parsed content
116
+         * @param \Phile\Model\Page page    the page model
117
+         */
118
+        Event::triggerEvent('after_parse_content', array('content' => &$content, 'page' => &$this));
119
+
120
+        return $content;
121
+    }
122
+
123
+    /**
124
+     * set content of page
125
+     *
126
+     * @param $content
127
+     */
128
+    public function setContent($content) {
129
+        $this->content = $content;
130
+    }
131
+
132
+    /**
133
+     * get raw (un-parsed) page content
134
+     *
135
+     * @return string
136
+     */
137
+    public function getRawContent() {
138
+        return $this->content;
139
+    }
140
+
141
+    /**
142
+     * get the meta model
143
+     *
144
+     * @return Meta
145
+     */
146
+    public function getMeta() {
147
+        return $this->meta;
148
+    }
149
+
150
+    /**
151
+     * parse the raw content
152
+     */
153
+    protected function parseRawData() {
154
+        $this->meta = new Meta($this->rawData);
155
+        // Remove only the optional, leading meta-block comment
156
+        $rawData = trim($this->rawData);
157
+        if (strncmp('<!--', $rawData, 4) === 0) {
158
+            // leading meta-block comment uses the <!-- --> style
159
+            $this->content = substr($rawData, max(4, strpos($rawData, '-->') + 3));
160
+        } elseif (strncmp('/*', $rawData, 2) === 0) {
161
+            // leading meta-block comment uses the /* */ style
162
+            $this->content = substr($rawData, strpos($rawData, '*/') + 2);
163
+        } else {
164
+            // no leading meta-block comment
165
+            $this->content = $rawData;
166
+        }
167
+    }
168
+
169
+    /**
170
+     * get the title of page from meta information
171
+     *
172
+     * @return string|null
173
+     */
174
+    public function getTitle() {
175
+        return $this->getMeta()->get('title');
176
+    }
177
+
178
+    /**
179
+     * get Phile $pageId
180
+     *
181
+     * @param string $filePath
182
+     * @return string
183
+     */
184
+    protected function buildPageId($filePath) {
185
+        $pageId = str_replace($this->contentFolder, '', $filePath);
186
+        $pageId = str_replace(CONTENT_EXT, '', $pageId);
187
+        $pageId = str_replace(DIRECTORY_SEPARATOR, '/', $pageId);
188
+        $pageId = ltrim($pageId, '/');
189
+        $pageId = preg_replace('/(?<=^|\/)index$/', '', $pageId);
190
+        return $pageId;
191
+    }
192
+
193
+    /**
194
+     * get the url of page
195
+     *
196
+     * @return string
197
+     */
198
+    public function getUrl() {
199
+        return (new Router)->urlForPage($this->pageId, false);
200
+    }
201
+
202
+    /**
203
+     * set the filepath of the page
204
+     *
205
+     * @param string $filePath
206
+     */
207
+    public function setFilePath($filePath) {
208
+        $this->filePath = $filePath;
209
+        $this->pageId = $this->buildPageId($this->filePath);
210
+    }
211
+
212
+    /**
213
+     * get the filepath of the page
214
+     *
215
+     * @return string
216
+     */
217
+    public function getFilePath() {
218
+        return $this->filePath;
219
+    }
220
+
221
+    /**
222
+     * get the folder name
223
+     *
224
+     * @return string
225
+     */
226
+    public function getFolder() {
227
+        return basename(dirname($this->getFilePath()));
228
+    }
229
+
230
+    public function getPageId() {
231
+        return $this->pageId;
232
+    }
233
+
234
+    /**
235
+     * get the previous page if one exist
236
+     *
237
+     * @return null|\Phile\Model\Page
238
+     */
239
+    public function getPreviousPage() {
240
+        $pageRepository = new \Phile\Repository\Page();
241
+        return $pageRepository->getPageOffset($this, -1);
242
+    }
243
+
244
+    /**
245
+     * get the next page if one exist
246
+     *
247
+     * @return null|\Phile\Model\Page
248
+     */
249
+    public function getNextPage() {
250
+        $pageRepository = new \Phile\Repository\Page();
251
+        return $pageRepository->getPageOffset($this, 1);
252
+    }
253 253
 }
Please login to merge, or discard this patch.