@@ -22,6 +22,9 @@ |
||
22 | 22 | register_shutdown_function("\\erdiko\\core\\ErrorHandler::fatalErrorShutdownHandler"); |
23 | 23 | } |
24 | 24 | |
25 | + /** |
|
26 | + * @param integer $errno |
|
27 | + */ |
|
25 | 28 | public static function errorHandler($errno, $errstr, $errfile, $errline) |
26 | 29 | { |
27 | 30 | $debug = \erdiko\core\ErrorHandler::isDebug(); |
@@ -14,73 +14,73 @@ |
||
14 | 14 | |
15 | 15 | class ErrorHandler |
16 | 16 | { |
17 | - public static function init() |
|
18 | - { |
|
19 | - ini_set('html_errors',0); // @todo review this line |
|
20 | - // error_reporting((E_ALL | E_STRICT)); // @note we shouldn't override by default, but we could inject |
|
21 | - set_error_handler("\\erdiko\\core\\ErrorHandler::errorHandler"); |
|
22 | - register_shutdown_function("\\erdiko\\core\\ErrorHandler::fatalErrorShutdownHandler"); |
|
23 | - } |
|
17 | + public static function init() |
|
18 | + { |
|
19 | + ini_set('html_errors',0); // @todo review this line |
|
20 | + // error_reporting((E_ALL | E_STRICT)); // @note we shouldn't override by default, but we could inject |
|
21 | + set_error_handler("\\erdiko\\core\\ErrorHandler::errorHandler"); |
|
22 | + register_shutdown_function("\\erdiko\\core\\ErrorHandler::fatalErrorShutdownHandler"); |
|
23 | + } |
|
24 | 24 | |
25 | - public static function errorHandler($errno, $errstr, $errfile, $errline) |
|
26 | - { |
|
27 | - $debug = \erdiko\core\ErrorHandler::isDebug(); |
|
28 | - if ( ! ( error_reporting() & $errno ) || empty( $errstr ) ) { |
|
29 | - return null; |
|
30 | - } |
|
25 | + public static function errorHandler($errno, $errstr, $errfile, $errline) |
|
26 | + { |
|
27 | + $debug = \erdiko\core\ErrorHandler::isDebug(); |
|
28 | + if ( ! ( error_reporting() & $errno ) || empty( $errstr ) ) { |
|
29 | + return null; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | $errorHook = "500"; |
33 | 33 | |
34 | - switch ( $errno ) { |
|
35 | - case E_USER_ERROR: |
|
36 | - $vars['msg_type'] = "USER ERROR"; |
|
37 | - $vars['msg_description'] = " Fatal error in line $errline of $errfile file"; |
|
38 | - $vars['msg_description'] .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")"; |
|
39 | - break; |
|
34 | + switch ( $errno ) { |
|
35 | + case E_USER_ERROR: |
|
36 | + $vars['msg_type'] = "USER ERROR"; |
|
37 | + $vars['msg_description'] = " Fatal error in line $errline of $errfile file"; |
|
38 | + $vars['msg_description'] .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")"; |
|
39 | + break; |
|
40 | 40 | |
41 | - case E_USER_WARNING: |
|
42 | - $vars['msg_type'] = "USER WARNING"; |
|
43 | - break; |
|
41 | + case E_USER_WARNING: |
|
42 | + $vars['msg_type'] = "USER WARNING"; |
|
43 | + break; |
|
44 | 44 | |
45 | - case E_USER_NOTICE: |
|
46 | - $vars['msg_type'] = "USER NOTICE"; |
|
47 | - break; |
|
45 | + case E_USER_NOTICE: |
|
46 | + $vars['msg_type'] = "USER NOTICE"; |
|
47 | + break; |
|
48 | 48 | |
49 | - case E_ERROR: |
|
50 | - $vars['msg_type'] = "ERROR"; |
|
51 | - $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
52 | - break; |
|
49 | + case E_ERROR: |
|
50 | + $vars['msg_type'] = "ERROR"; |
|
51 | + $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
52 | + break; |
|
53 | 53 | |
54 | - default: |
|
55 | - $vars['msg_type'] = "Type of error: [$errno] $errstr"; |
|
56 | - $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
57 | - break; |
|
58 | - } |
|
54 | + default: |
|
55 | + $vars['msg_type'] = "Type of error: [$errno] $errstr"; |
|
56 | + $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
57 | + break; |
|
58 | + } |
|
59 | 59 | |
60 | - $vars['code'] = $errno; |
|
61 | - $vars['error'] = trim($errstr); |
|
62 | - $vars['path_info'] = $errfile . " on line " . $errline; |
|
63 | - $vars['debug'] = $debug; |
|
60 | + $vars['code'] = $errno; |
|
61 | + $vars['error'] = trim($errstr); |
|
62 | + $vars['path_info'] = $errfile . " on line " . $errline; |
|
63 | + $vars['debug'] = $debug; |
|
64 | 64 | |
65 | - ToroHook::fire($errorHook, $vars ); |
|
65 | + ToroHook::fire($errorHook, $vars ); |
|
66 | 66 | |
67 | - return false; |
|
68 | - } |
|
67 | + return false; |
|
68 | + } |
|
69 | 69 | |
70 | - public static function fatalErrorShutdownHandler() |
|
71 | - { |
|
72 | - $last_error = error_get_last(); |
|
73 | - static::errorHandler(E_ERROR, |
|
74 | - $last_error['message'], $last_error['file'], $last_error['line']); |
|
75 | - } |
|
70 | + public static function fatalErrorShutdownHandler() |
|
71 | + { |
|
72 | + $last_error = error_get_last(); |
|
73 | + static::errorHandler(E_ERROR, |
|
74 | + $last_error['message'], $last_error['file'], $last_error['line']); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * isDebug |
|
79 | - * |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public static function isDebug() |
|
83 | - { |
|
84 | - return (getenv("ERDIKO_DEBUG")=='1'); |
|
85 | - } |
|
77 | + /** |
|
78 | + * isDebug |
|
79 | + * |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public static function isDebug() |
|
83 | + { |
|
84 | + return (getenv("ERDIKO_DEBUG")=='1'); |
|
85 | + } |
|
86 | 86 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | public static function init() |
18 | 18 | { |
19 | - ini_set('html_errors',0); // @todo review this line |
|
19 | + ini_set('html_errors', 0); // @todo review this line |
|
20 | 20 | // error_reporting((E_ALL | E_STRICT)); // @note we shouldn't override by default, but we could inject |
21 | 21 | set_error_handler("\\erdiko\\core\\ErrorHandler::errorHandler"); |
22 | 22 | register_shutdown_function("\\erdiko\\core\\ErrorHandler::fatalErrorShutdownHandler"); |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | public static function errorHandler($errno, $errstr, $errfile, $errline) |
26 | 26 | { |
27 | 27 | $debug = \erdiko\core\ErrorHandler::isDebug(); |
28 | - if ( ! ( error_reporting() & $errno ) || empty( $errstr ) ) { |
|
28 | + if (!(error_reporting() & $errno) || empty($errstr)) { |
|
29 | 29 | return null; |
30 | 30 | } |
31 | 31 | |
32 | 32 | $errorHook = "500"; |
33 | 33 | |
34 | - switch ( $errno ) { |
|
34 | + switch ($errno) { |
|
35 | 35 | case E_USER_ERROR: |
36 | 36 | $vars['msg_type'] = "USER ERROR"; |
37 | 37 | $vars['msg_description'] = " Fatal error in line $errline of $errfile file"; |
38 | - $vars['msg_description'] .= ", PHP " . PHP_VERSION . " (" . PHP_OS . ")"; |
|
38 | + $vars['msg_description'] .= ", PHP ".PHP_VERSION." (".PHP_OS.")"; |
|
39 | 39 | break; |
40 | 40 | |
41 | 41 | case E_USER_WARNING: |
@@ -48,21 +48,21 @@ discard block |
||
48 | 48 | |
49 | 49 | case E_ERROR: |
50 | 50 | $vars['msg_type'] = "ERROR"; |
51 | - $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
51 | + $vars['msg_description'] = print_r(debug_backtrace(), 1); |
|
52 | 52 | break; |
53 | 53 | |
54 | 54 | default: |
55 | 55 | $vars['msg_type'] = "Type of error: [$errno] $errstr"; |
56 | - $vars['msg_description'] = print_r(debug_backtrace(),1); |
|
56 | + $vars['msg_description'] = print_r(debug_backtrace(), 1); |
|
57 | 57 | break; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $vars['code'] = $errno; |
61 | 61 | $vars['error'] = trim($errstr); |
62 | - $vars['path_info'] = $errfile . " on line " . $errline; |
|
63 | - $vars['debug'] = $debug; |
|
62 | + $vars['path_info'] = $errfile." on line ".$errline; |
|
63 | + $vars['debug'] = $debug; |
|
64 | 64 | |
65 | - ToroHook::fire($errorHook, $vars ); |
|
65 | + ToroHook::fire($errorHook, $vars); |
|
66 | 66 | |
67 | 67 | return false; |
68 | 68 | } |
@@ -81,6 +81,6 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public static function isDebug() |
83 | 83 | { |
84 | - return (getenv("ERDIKO_DEBUG")=='1'); |
|
84 | + return (getenv("ERDIKO_DEBUG") == '1'); |
|
85 | 85 | } |
86 | 86 | } |
@@ -14,43 +14,43 @@ |
||
14 | 14 | |
15 | 15 | class FlashMessages |
16 | 16 | { |
17 | - /** |
|
18 | - * Reset the messages |
|
19 | - */ |
|
20 | - public static function reset() |
|
21 | - { |
|
22 | - $_SESSION['erdiko_flash_message'] = array(); |
|
23 | - } |
|
17 | + /** |
|
18 | + * Reset the messages |
|
19 | + */ |
|
20 | + public static function reset() |
|
21 | + { |
|
22 | + $_SESSION['erdiko_flash_message'] = array(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Set flash message |
|
27 | - * Add a message to the array |
|
28 | - * @note: Should we restrict/limit types to only the 4 listed in the header? |
|
29 | - * @param string $message |
|
30 | - * @param string $type |
|
31 | - */ |
|
32 | - public static function set($message, $type = 'danger') |
|
33 | - { |
|
34 | - $_SESSION['erdiko_flash_message'][] = array( |
|
35 | - 'text' => $message, |
|
36 | - 'type' => $type |
|
37 | - ); |
|
25 | + /** |
|
26 | + * Set flash message |
|
27 | + * Add a message to the array |
|
28 | + * @note: Should we restrict/limit types to only the 4 listed in the header? |
|
29 | + * @param string $message |
|
30 | + * @param string $type |
|
31 | + */ |
|
32 | + public static function set($message, $type = 'danger') |
|
33 | + { |
|
34 | + $_SESSION['erdiko_flash_message'][] = array( |
|
35 | + 'text' => $message, |
|
36 | + 'type' => $type |
|
37 | + ); |
|
38 | 38 | |
39 | - $_SESSION['erdiko_flash_message']; |
|
40 | - } |
|
39 | + $_SESSION['erdiko_flash_message']; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Get flash messages |
|
44 | - * @return array $messages |
|
45 | - */ |
|
46 | - public static function get() |
|
47 | - { |
|
48 | - $messages = array(); |
|
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | - $messages = $_SESSION['erdiko_flash_message']; |
|
51 | - self::reset(); |
|
42 | + /** |
|
43 | + * Get flash messages |
|
44 | + * @return array $messages |
|
45 | + */ |
|
46 | + public static function get() |
|
47 | + { |
|
48 | + $messages = array(); |
|
49 | + if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | + $messages = $_SESSION['erdiko_flash_message']; |
|
51 | + self::reset(); |
|
52 | 52 | |
53 | - return $messages; |
|
54 | - } |
|
53 | + return $messages; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -46,7 +46,7 @@ |
||
46 | 46 | public static function get() |
47 | 47 | { |
48 | 48 | $messages = array(); |
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
49 | + if (isset($_SESSION['erdiko_flash_message'])) |
|
50 | 50 | $messages = $_SESSION['erdiko_flash_message']; |
51 | 51 | self::reset(); |
52 | 52 |
@@ -46,8 +46,9 @@ |
||
46 | 46 | public static function get() |
47 | 47 | { |
48 | 48 | $messages = array(); |
49 | - if(isset($_SESSION['erdiko_flash_message'])) |
|
50 | - $messages = $_SESSION['erdiko_flash_message']; |
|
49 | + if(isset($_SESSION['erdiko_flash_message'])) { |
|
50 | + $messages = $_SESSION['erdiko_flash_message']; |
|
51 | + } |
|
51 | 52 | self::reset(); |
52 | 53 | |
53 | 54 | return $messages; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Read JSON config file and return array |
54 | 54 | * |
55 | - * @param string $file |
|
55 | + * @param string $filename |
|
56 | 56 | * @return array $config |
57 | 57 | */ |
58 | 58 | public static function getConfigFile($filename) |
@@ -75,6 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Get configuration |
78 | + * @param string $context |
|
78 | 79 | */ |
79 | 80 | public static function getConfig($name = 'application', $context = null) |
80 | 81 | { |
@@ -89,6 +90,7 @@ discard block |
||
89 | 90 | * Get the compiled application routes from the config files |
90 | 91 | * |
91 | 92 | * @todo cache the loaded/compiled routes |
93 | + * @param string $context |
|
92 | 94 | */ |
93 | 95 | public static function getRoutes($context = null) |
94 | 96 | { |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * Log Object |
18 | 18 | */ |
19 | - protected static $_logObject=null; // @todo get rid of this |
|
19 | + protected static $_logObject = null; // @todo get rid of this |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Serve your site |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public static function serve($context = null) |
28 | 28 | { |
29 | - if(empty($context)) |
|
29 | + if (empty($context)) |
|
30 | 30 | $context = getenv('ERDIKO_CONTEXT'); |
31 | 31 | |
32 | 32 | $routes = static::getRoutes($context); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function getConfig($name = 'application', $context = null) |
80 | 80 | { |
81 | - if($context == null) |
|
81 | + if ($context == null) |
|
82 | 82 | $context = getenv('ERDIKO_CONTEXT'); |
83 | 83 | |
84 | 84 | $filename = ERDIKO_APP."/config/{$context}/{$name}.json"; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function getRoutes($context = null) |
94 | 94 | { |
95 | - if($context == null) |
|
95 | + if ($context == null) |
|
96 | 96 | $context = getenv('ERDIKO_CONTEXT'); |
97 | 97 | $file = ERDIKO_APP."/config/{$context}/routes.json"; |
98 | 98 | $applicationConfig = static::getConfigFile($file); |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public static function sendEmail($toEmail, $subject, $body, $fromEmail) |
108 | 108 | { |
109 | - $headers = "From: $fromEmail\r\n" . |
|
110 | - "Reply-To: $fromEmail\r\n" . |
|
111 | - "X-Mailer: PHP/" . phpversion(); |
|
109 | + $headers = "From: $fromEmail\r\n". |
|
110 | + "Reply-To: $fromEmail\r\n". |
|
111 | + "X-Mailer: PHP/".phpversion(); |
|
112 | 112 | |
113 | 113 | return mail($toEmail, $subject, $body, $headers); |
114 | 114 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public static function log($level, $message, array $context = array()) |
129 | 129 | { |
130 | - if(static::$_logObject==null) |
|
130 | + if (static::$_logObject == null) |
|
131 | 131 | { |
132 | 132 | $erdikoContext = getenv('ERDIKO_CONTEXT'); |
133 | 133 | $config = static::getConfig("application", $erdikoContext); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir); |
138 | 138 | } |
139 | 139 | |
140 | - if(empty($level)) |
|
140 | + if (empty($level)) |
|
141 | 141 | $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience |
142 | 142 | |
143 | 143 | return static::$_logObject->log($level, $message, $context); |
@@ -26,8 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public static function serve($context = null) |
28 | 28 | { |
29 | - if(empty($context)) |
|
30 | - $context = getenv('ERDIKO_CONTEXT'); |
|
29 | + if(empty($context)) { |
|
30 | + $context = getenv('ERDIKO_CONTEXT'); |
|
31 | + } |
|
31 | 32 | |
32 | 33 | $routes = static::getRoutes($context); |
33 | 34 | Toro::serve($routes); |
@@ -78,8 +79,9 @@ discard block |
||
78 | 79 | */ |
79 | 80 | public static function getConfig($name = 'application', $context = null) |
80 | 81 | { |
81 | - if($context == null) |
|
82 | - $context = getenv('ERDIKO_CONTEXT'); |
|
82 | + if($context == null) { |
|
83 | + $context = getenv('ERDIKO_CONTEXT'); |
|
84 | + } |
|
83 | 85 | |
84 | 86 | $filename = ERDIKO_APP."/config/{$context}/{$name}.json"; |
85 | 87 | return static::getConfigFile($filename); |
@@ -92,8 +94,9 @@ discard block |
||
92 | 94 | */ |
93 | 95 | public static function getRoutes($context = null) |
94 | 96 | { |
95 | - if($context == null) |
|
96 | - $context = getenv('ERDIKO_CONTEXT'); |
|
97 | + if($context == null) { |
|
98 | + $context = getenv('ERDIKO_CONTEXT'); |
|
99 | + } |
|
97 | 100 | $file = ERDIKO_APP."/config/{$context}/routes.json"; |
98 | 101 | $applicationConfig = static::getConfigFile($file); |
99 | 102 | |
@@ -137,8 +140,10 @@ discard block |
||
137 | 140 | static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir); |
138 | 141 | } |
139 | 142 | |
140 | - if(empty($level)) |
|
141 | - $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience |
|
143 | + if(empty($level)) { |
|
144 | + $level = \Psr\Log\LogLevel::DEBUG; |
|
145 | + } |
|
146 | + // Default to debug for convenience |
|
142 | 147 | |
143 | 148 | return static::$_logObject->log($level, $message, $context); |
144 | 149 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Get Cache Object |
51 | 51 | * |
52 | - * @return Memcache $memcacheObj |
|
52 | + * @return \Memcached $memcacheObj |
|
53 | 53 | * @note Please do not modify data if you use the put function in this class |
54 | 54 | */ |
55 | 55 | public function getObject() |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Check if the key exists in cache |
106 | 106 | * |
107 | 107 | * @parm mixed $key |
108 | - * @return true if the key exist in cache |
|
109 | - * @return false if the key does not exist in cache |
|
108 | + * @return boolean if the key exist in cache |
|
109 | + * @return boolean if the key does not exist in cache |
|
110 | 110 | * |
111 | 111 | */ |
112 | 112 | public function has($key) |
@@ -31,8 +31,8 @@ |
||
31 | 31 | $this->memcacheObj = new \Memcached; |
32 | 32 | |
33 | 33 | $config = \erdiko\core\Helper::getConfig("local/cache"); |
34 | - $host=$config["memcached"]["host"]; |
|
35 | - $port=$config["memcached"]["port"]; |
|
34 | + $host = $config["memcached"]["host"]; |
|
35 | + $port = $config["memcached"]["port"]; |
|
36 | 36 | $cacheAvailable = $this->memcacheObj->addServer($host, $port); |
37 | 37 | |
38 | 38 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @param string $filename |
122 | 122 | * @param string $pathTo |
123 | - * @param string $pathToFrom |
|
124 | - * @return bool |
|
123 | + * @param string $pathFrom |
|
124 | + * @return boolean|null |
|
125 | 125 | */ |
126 | 126 | public function move($filename, $pathTo, $pathFrom = null) |
127 | 127 | { |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * Rename a file |
141 | 141 | * |
142 | 142 | * @param string $oldName |
143 | - * @param string $pathTo |
|
144 | - * @param string $pathToFrom |
|
143 | + * @param string $pathToFile |
|
144 | + * @param string $pathToFile |
|
145 | 145 | * @return bool |
146 | 146 | * @todo consider merging rename() and move() into one method |
147 | 147 | */ |
@@ -22,10 +22,10 @@ |
||
22 | 22 | protected $_filePath = null; |
23 | 23 | |
24 | 24 | /** |
25 | - * Contructor |
|
26 | - * |
|
27 | - * @param string $defaultPath |
|
28 | - */ |
|
25 | + * Contructor |
|
26 | + * |
|
27 | + * @param string $defaultPath |
|
28 | + */ |
|
29 | 29 | public function __construct($defaultPath = null) |
30 | 30 | { |
31 | 31 | if (isset($defaultPath)) { |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | public function __construct($defaultPath = null) |
30 | 30 | { |
31 | 31 | if (isset($defaultPath)) { |
32 | - $this->_filePath=$defaultPath; |
|
32 | + $this->_filePath = $defaultPath; |
|
33 | 33 | } else { |
34 | - $rootFolder=dirname(dirname(dirname(__DIR__))); |
|
35 | - $this->_filePath=$rootFolder."/var"; |
|
34 | + $rootFolder = dirname(dirname(dirname(__DIR__))); |
|
35 | + $this->_filePath = $rootFolder."/var"; |
|
36 | 36 | } |
37 | 37 | if (!is_dir($this->_filePath)) { |
38 | 38 | mkdir($this->_filePath, 0775, true); |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function read($filename, $pathToFile = null) |
88 | 88 | { |
89 | - if(!$this->fileExists($filename, $pathToFile)) |
|
89 | + if (!$this->fileExists($filename, $pathToFile)) |
|
90 | 90 | throw new \Exception("File, '{$filename}', does not exist."); |
91 | 91 | |
92 | - if ($pathToFile==null) { |
|
92 | + if ($pathToFile == null) { |
|
93 | 93 | return file_get_contents($this->_filePath."/".$filename); |
94 | 94 | } else { |
95 | 95 | return file_get_contents($pathToFile."/".$filename); |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function delete($filename, $pathToFile = null) |
107 | 107 | { |
108 | - if ($pathToFile==null) { |
|
109 | - $pathToFile=$this->_filePath; |
|
108 | + if ($pathToFile == null) { |
|
109 | + $pathToFile = $this->_filePath; |
|
110 | 110 | } |
111 | 111 | if (file_exists($pathToFile."/".$filename)) { |
112 | 112 | return unlink($pathToFile."/".$filename); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function move($filename, $pathTo, $pathFrom = null) |
127 | 127 | { |
128 | - if ($pathFrom==null) { |
|
129 | - $pathFrom=$this->_filePath; |
|
128 | + if ($pathFrom == null) { |
|
129 | + $pathFrom = $this->_filePath; |
|
130 | 130 | } |
131 | 131 | if (file_exists($pathFrom."/".$filename)) { |
132 | 132 | $this->createDir($pathTo); |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function rename($oldName, $newName, $pathToFile = null) |
149 | 149 | { |
150 | - if ($pathToFile==null) { |
|
151 | - $pathToFile=$this->_filePath; |
|
150 | + if ($pathToFile == null) { |
|
151 | + $pathToFile = $this->_filePath; |
|
152 | 152 | } |
153 | 153 | if (file_exists($pathToFile."/".$oldName)) { |
154 | 154 | $this->createDir($pathToFile); |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function copy($filename, $newFilePath, $newFileName = null, $pathToFile = null) |
171 | 171 | { |
172 | - if ($pathToFile==null) { |
|
173 | - $pathToFile=$this->_filePath; |
|
172 | + if ($pathToFile == null) { |
|
173 | + $pathToFile = $this->_filePath; |
|
174 | 174 | } |
175 | - if ($newFileName==null) { |
|
176 | - $newFileName=$filename; |
|
175 | + if ($newFileName == null) { |
|
176 | + $newFileName = $filename; |
|
177 | 177 | } |
178 | 178 | if (file_exists($pathToFile."/".$filename)) { |
179 | 179 | return copy($pathToFile."/".$filename, $newFilePath."/".$newFileName); |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function fileExists($filename, $pathToFile = null) |
193 | 193 | { |
194 | - if ($pathToFile==null) { |
|
195 | - $pathToFile=$this->_filePath; |
|
194 | + if ($pathToFile == null) { |
|
195 | + $pathToFile = $this->_filePath; |
|
196 | 196 | } |
197 | 197 | return file_exists($pathToFile."/".$filename); |
198 | 198 | } |
@@ -86,8 +86,9 @@ |
||
86 | 86 | */ |
87 | 87 | public function read($filename, $pathToFile = null) |
88 | 88 | { |
89 | - if(!$this->fileExists($filename, $pathToFile)) |
|
90 | - throw new \Exception("File, '{$filename}', does not exist."); |
|
89 | + if(!$this->fileExists($filename, $pathToFile)) { |
|
90 | + throw new \Exception("File, '{$filename}', does not exist."); |
|
91 | + } |
|
91 | 92 | |
92 | 93 | if ($pathToFile==null) { |
93 | 94 | return file_get_contents($this->_filePath."/".$filename); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param string $template , Theme Object (Contaier) |
36 | 36 | * @param mixed $data |
37 | - * @param string $theme |
|
37 | + * @param string $themeName |
|
38 | 38 | */ |
39 | 39 | public function __construct($template = null, $data = array(), $themeName = null) |
40 | 40 | { |
@@ -97,7 +97,6 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Get Theme Root Folder |
99 | 99 | * |
100 | - * @param string $folder |
|
101 | 100 | */ |
102 | 101 | public function getThemeRootFolder() |
103 | 102 | { |
@@ -171,7 +171,7 @@ |
||
171 | 171 | */ |
172 | 172 | public function getRegion($name) |
173 | 173 | { |
174 | - if(array_key_exists($name, $this->_regions)) { |
|
174 | + if (array_key_exists($name, $this->_regions)) { |
|
175 | 175 | $html = (is_subclass_of($this->_regions[$name], 'erdiko\core\Container')) ? |
176 | 176 | $this->_regions[$name]->toHtml() : $this->_regions[$name]; |
177 | 177 | } else { |
@@ -52,7 +52,6 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Get template |
54 | 54 | * |
55 | - * @param string $template |
|
56 | 55 | */ |
57 | 56 | public function getTemplate() |
58 | 57 | { |
@@ -62,7 +61,6 @@ discard block |
||
62 | 61 | /** |
63 | 62 | * Get default template name |
64 | 63 | * |
65 | - * @param string $template |
|
66 | 64 | */ |
67 | 65 | public function getDefaultTemplate() |
68 | 66 | { |
@@ -82,7 +80,7 @@ discard block |
||
82 | 80 | /** |
83 | 81 | * Set template root folder |
84 | 82 | * |
85 | - * @param string $TemplateRootFolder |
|
83 | + * @param string $templateRootFolder |
|
86 | 84 | */ |
87 | 85 | public function setTemplateRootFolder($templateRootFolder) |
88 | 86 | { |
@@ -119,6 +117,7 @@ discard block |
||
119 | 117 | |
120 | 118 | /** |
121 | 119 | * Set Template folder |
120 | + * @param string $templateFolder |
|
122 | 121 | */ |
123 | 122 | public function setTemplateFolder($templateFolder) |
124 | 123 | { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | // Capitalize first letter of the key to preserve camel case convention naming |
165 | 165 | $method = 'set'.ucfirst($key); |
166 | - if(is_callable(array($this, $method))) { |
|
166 | + if (is_callable(array($this, $method))) { |
|
167 | 167 | $this->$method($value); // Execute the native setter function |
168 | 168 | } else { |
169 | 169 | $this->_data[$key] = $value; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | { |
175 | 175 | $value = null; |
176 | 176 | |
177 | - if(array_key_exists($key, $this->_data)) |
|
177 | + if (array_key_exists($key, $this->_data)) |
|
178 | 178 | $value = $this->_data[$key]; |
179 | 179 | |
180 | 180 | return $value; |
@@ -174,8 +174,9 @@ |
||
174 | 174 | { |
175 | 175 | $value = null; |
176 | 176 | |
177 | - if(array_key_exists($key, $this->_data)) |
|
178 | - $value = $this->_data[$key]; |
|
177 | + if(array_key_exists($key, $this->_data)) { |
|
178 | + $value = $this->_data[$key]; |
|
179 | + } |
|
179 | 180 | |
180 | 181 | return $value; |
181 | 182 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param string $name |
207 | 207 | * @param string $cssFile URL of injected css file |
208 | 208 | * @param int $order |
209 | - * @param boolean $active defaults to 1 |
|
209 | + * @param integer $active defaults to 1 |
|
210 | 210 | * @todo need to resolve order of merging and/or eliminate/refactor this function |
211 | 211 | */ |
212 | 212 | public function addCss($name, $cssFile, $order = 10, $active = 1) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param string $name |
240 | 240 | * @param string $jsFile URL of js file |
241 | 241 | * @param int $order |
242 | - * @param boolean $active defaults to 1 |
|
242 | + * @param integer $active defaults to 1 |
|
243 | 243 | * @todo same issue as addCss |
244 | 244 | */ |
245 | 245 | public function addJs($name, $jsFile, $order = 10, $active = 1) |
@@ -254,7 +254,6 @@ discard block |
||
254 | 254 | /** |
255 | 255 | * Get Theme Root Folder |
256 | 256 | * |
257 | - * @param string $folder |
|
258 | 257 | */ |
259 | 258 | public function getThemeRootFolder() |
260 | 259 | { |
@@ -316,6 +315,7 @@ discard block |
||
316 | 315 | * Set the theme name, the name is also the id of the theme |
317 | 316 | * |
318 | 317 | * @param string Theme name |
318 | + * @param string $name |
|
319 | 319 | */ |
320 | 320 | public function setName($name) |
321 | 321 | { |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function addCss($name, $cssFile, $order = 10, $active = 1) |
212 | 212 | { |
213 | - $this->_data['css'][$name] = array( |
|
213 | + $this->_data['css'][$name] = array( |
|
214 | 214 | 'file' => $cssFile, |
215 | 215 | 'order' => $order, |
216 | 216 | 'active' => $active |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | ); |
248 | 248 | } |
249 | 249 | |
250 | - /** |
|
251 | - * Get Theme Root Folder |
|
252 | - * |
|
253 | - * @param string $folder |
|
254 | - */ |
|
250 | + /** |
|
251 | + * Get Theme Root Folder |
|
252 | + * |
|
253 | + * @param string $folder |
|
254 | + */ |
|
255 | 255 | public function getThemeRootFolder() |
256 | 256 | { |
257 | 257 | return $this->_themeRootFolder; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function getThemeConfig() |
77 | 77 | { |
78 | 78 | if (empty($this->_themeConfig)) { |
79 | - $file = $this->getThemeFolder() . 'theme.json'; |
|
79 | + $file = $this->getThemeFolder().'theme.json'; |
|
80 | 80 | $this->_themeConfig = Helper::getConfigFile($file); |
81 | 81 | } |
82 | 82 | return $this->_themeConfig; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function getMeta() |
91 | 91 | { |
92 | 92 | if (isset($this->_contextConfig['site']['meta'])) { |
93 | - return array_merge($this->_contextConfig['site']['meta'],$this->_data['meta']); |
|
93 | + return array_merge($this->_contextConfig['site']['meta'], $this->_data['meta']); |
|
94 | 94 | } else { |
95 | 95 | return $this->_data['meta']; |
96 | 96 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | foreach ($this->getMeta() as $name => $content) |
129 | 129 | { |
130 | - if(is_array($content)) { |
|
131 | - foreach($content as $cont) |
|
130 | + if (is_array($content)) { |
|
131 | + foreach ($content as $cont) |
|
132 | 132 | $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n"; |
133 | 133 | } else { |
134 | 134 | $html .= "<meta name=\"{$name}\" content=\"{$content}\">\n"; |
@@ -62,8 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getContextConfig() |
64 | 64 | { |
65 | - if (empty($this->_contextConfig)) |
|
66 | - $this->_contextConfig = Helper::getConfig('application', $this->_context); |
|
65 | + if (empty($this->_contextConfig)) { |
|
66 | + $this->_contextConfig = Helper::getConfig('application', $this->_context); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | return $this->_contextConfig; |
69 | 70 | } |
@@ -128,8 +129,9 @@ discard block |
||
128 | 129 | foreach ($this->getMeta() as $name => $content) |
129 | 130 | { |
130 | 131 | if(is_array($content)) { |
131 | - foreach($content as $cont) |
|
132 | - $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n"; |
|
132 | + foreach($content as $cont) { |
|
133 | + $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n"; |
|
134 | + } |
|
133 | 135 | } else { |
134 | 136 | $html .= "<meta name=\"{$name}\" content=\"{$content}\">\n"; |
135 | 137 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * Constructor |
19 | 19 | * @param string $template |
20 | 20 | * @param mixed $data |
21 | - * @param string $templateFolder |
|
21 | + * @param string $templateRootFolder |
|
22 | 22 | */ |
23 | 23 | public function __construct($template = null, $data = null, $templateRootFolder = ERDIKO_APP) |
24 | 24 | { |