@@ -1,54 +1,54 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | return [ |
| 3 | 3 | |
| 4 | - 'logger'=>[ |
|
| 5 | - 'level'=>'debug' |
|
| 6 | - ], |
|
| 4 | + 'logger'=>[ |
|
| 5 | + 'level'=>'debug' |
|
| 6 | + ], |
|
| 7 | 7 | |
| 8 | - 'view'=>[ |
|
| 9 | - 'path'=>[ |
|
| 10 | - '../templates/' |
|
| 11 | - ], |
|
| 8 | + 'view'=>[ |
|
| 9 | + 'path'=>[ |
|
| 10 | + '../templates/' |
|
| 11 | + ], |
|
| 12 | 12 | 'default_template'=>'default', |
| 13 | - 'default_engine'=>'mustache' |
|
| 14 | - ], |
|
| 13 | + 'default_engine'=>'mustache' |
|
| 14 | + ], |
|
| 15 | 15 | |
| 16 | - 'routes' => [ |
|
| 17 | - 'templates' => [ |
|
| 18 | - 'default' => [ |
|
| 19 | - 'ident'=>'default' |
|
| 20 | - ], |
|
| 21 | - 'example' => [ |
|
| 22 | - 'ident'=>'example', |
|
| 23 | - 'controller'=>null, |
|
| 24 | - 'methods'=>['GET'], |
|
| 25 | - 'group'=>null, |
|
| 26 | - 'template'=>'example', |
|
| 27 | - 'engine'=>'mustache', |
|
| 28 | - 'cache'=>[ |
|
| 29 | - 'active'=>true, |
|
| 30 | - 'key'=>'route/{{ident}}/{{lang}}/' |
|
| 31 | - ], |
|
| 32 | - 'options'=>[] |
|
| 33 | - ] |
|
| 34 | - ], |
|
| 35 | - 'actions' => [ |
|
| 36 | - 'default' => [], |
|
| 37 | - 'example' => [ |
|
| 38 | - 'ident'=>'example', |
|
| 39 | - 'controller'=>null, |
|
| 40 | - 'methods'=>['POST'], |
|
| 41 | - 'group'=>null |
|
| 42 | - ] |
|
| 43 | - ], |
|
| 44 | - 'scripts' => [ |
|
| 45 | - 'example' => [ |
|
| 46 | - 'ident'=>'example', |
|
| 47 | - 'controller'=>null, |
|
| 48 | - 'methods'=>['GET'], |
|
| 49 | - 'group'=>null |
|
| 50 | - ] |
|
| 51 | - ] |
|
| 52 | - ] |
|
| 16 | + 'routes' => [ |
|
| 17 | + 'templates' => [ |
|
| 18 | + 'default' => [ |
|
| 19 | + 'ident'=>'default' |
|
| 20 | + ], |
|
| 21 | + 'example' => [ |
|
| 22 | + 'ident'=>'example', |
|
| 23 | + 'controller'=>null, |
|
| 24 | + 'methods'=>['GET'], |
|
| 25 | + 'group'=>null, |
|
| 26 | + 'template'=>'example', |
|
| 27 | + 'engine'=>'mustache', |
|
| 28 | + 'cache'=>[ |
|
| 29 | + 'active'=>true, |
|
| 30 | + 'key'=>'route/{{ident}}/{{lang}}/' |
|
| 31 | + ], |
|
| 32 | + 'options'=>[] |
|
| 33 | + ] |
|
| 34 | + ], |
|
| 35 | + 'actions' => [ |
|
| 36 | + 'default' => [], |
|
| 37 | + 'example' => [ |
|
| 38 | + 'ident'=>'example', |
|
| 39 | + 'controller'=>null, |
|
| 40 | + 'methods'=>['POST'], |
|
| 41 | + 'group'=>null |
|
| 42 | + ] |
|
| 43 | + ], |
|
| 44 | + 'scripts' => [ |
|
| 45 | + 'example' => [ |
|
| 46 | + 'ident'=>'example', |
|
| 47 | + 'controller'=>null, |
|
| 48 | + 'methods'=>['GET'], |
|
| 49 | + 'group'=>null |
|
| 50 | + ] |
|
| 51 | + ] |
|
| 52 | + ] |
|
| 53 | 53 | ]; |
| 54 | 54 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | $container = $app->getContainer(); |
| 12 | 12 | |
| 13 | 13 | // PSR-3 logger with monolog |
| 14 | -$container['logger'] = function ($c) { |
|
| 14 | +$container['logger'] = function($c) { |
|
| 15 | 15 | $logger = new MonologLogger('Charcoal'); |
| 16 | 16 | $logger->pushProcessor(new UidProcessor()); |
| 17 | 17 | $logger->pushHandler(new MonologStreamHandler('charcoal.app.log', \Monolog\Logger::DEBUG)); |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | if ($name instanceof TranslationStringInterface) { |
| 95 | 95 | $config = $name->available_langs(); |
| 96 | 96 | } elseif (is_array($name)) { |
| 97 | - $config = [ 'languages' => array_keys($name) ]; |
|
| 97 | + $config = ['languages' => array_keys($name)]; |
|
| 98 | 98 | } else { |
| 99 | 99 | $config = null; |
| 100 | 100 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | if ($this->module_manager == null) { |
| 103 | 103 | $config = $this->config(); |
| 104 | - $modules = (isset($config['modules']) ? $config['modules'] : [] ); |
|
| 104 | + $modules = (isset($config['modules']) ? $config['modules'] : []); |
|
| 105 | 105 | $this->module_manager = new ModuleManager([ |
| 106 | 106 | 'config' => $modules, |
| 107 | 107 | 'app' => $this->app, |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | if ($this->route_manager === null) { |
| 120 | 120 | $config = $this->config(); |
| 121 | - $routes = (isset($config['routes']) ? $config['routes'] : [] ); |
|
| 121 | + $routes = (isset($config['routes']) ? $config['routes'] : []); |
|
| 122 | 122 | $route_manager = new RouteManager([ |
| 123 | 123 | 'config' => $routes, |
| 124 | 124 | 'app' => $this->app, |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | if ($this->middleware_manager === null) { |
| 137 | 137 | $config = $this->config(); |
| 138 | - $middlewares = (isset($config['middlewares']) ? $config['middlewares'] : [] ); |
|
| 138 | + $middlewares = (isset($config['middlewares']) ? $config['middlewares'] : []); |
|
| 139 | 139 | $middleware_manager = new MiddlewareManager([ |
| 140 | 140 | 'config' => $middlewares, |
| 141 | 141 | 'app' => $this->app, |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | // For now, need to rely on a catch-all... |
| 228 | 228 | $this->app->get( |
| 229 | 229 | '{catchall:.*}', |
| 230 | - function ( |
|
| 230 | + function( |
|
| 231 | 231 | RequestInterface $request, |
| 232 | 232 | ResponseInterface $response, |
| 233 | 233 | $args |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | * Initialize the Charcoal App before running (with SlimApp). |
| 163 | 163 | * |
| 164 | 164 | * @param boolean $silent If true, will run in silent mot (no response). |
| 165 | - * @return App Chainable |
|
| 165 | + * @return ResponseInterface Chainable |
|
| 166 | 166 | */ |
| 167 | 167 | public function run($silent = false) |
| 168 | 168 | { |
@@ -51,11 +51,11 @@ |
||
| 51 | 51 | { |
| 52 | 52 | return $c['response'] |
| 53 | 53 | ->withStatus(500) |
| 54 | - ->withHeader('Content-Type', 'text/html') |
|
| 55 | - ->write( |
|
| 54 | + ->withHeader('Content-Type', 'text/html') |
|
| 55 | + ->write( |
|
| 56 | 56 | sprintf('Something went wrong! (%s)'."\n", $exception->getMessage()) |
| 57 | 57 | ); |
| 58 | - }; |
|
| 58 | + }; |
|
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | // Slim is the main app |
@@ -27,32 +27,32 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $container['charcoal/app/config'] = function($c) { |
| 29 | 29 | $config = new AppConfig(); |
| 30 | - $config->add_file(__DIR__.'/../config/config.php'); |
|
| 30 | + $config->add_file(__DIR__ . '/../config/config.php'); |
|
| 31 | 31 | return $config; |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | // Handle "404 Not Found" |
| 35 | -$container['notFoundHandler'] = function ($c) |
|
| 35 | +$container['notFoundHandler'] = function($c) |
|
| 36 | 36 | { |
| 37 | - return function ($request, $response) use ($c) |
|
| 37 | + return function($request, $response) use ($c) |
|
| 38 | 38 | { |
| 39 | 39 | return $c['response'] |
| 40 | 40 | ->withStatus(404) |
| 41 | 41 | ->withHeader('Content-Type', 'text/html') |
| 42 | - ->write('Page not found'."\n"); |
|
| 42 | + ->write('Page not found' . "\n"); |
|
| 43 | 43 | }; |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | // Handle "500 Server Error" |
| 47 | -$container['errorHandler'] = function ($c) |
|
| 47 | +$container['errorHandler'] = function($c) |
|
| 48 | 48 | { |
| 49 | - return function ($request, $response, $exception) use ($c) |
|
| 49 | + return function($request, $response, $exception) use ($c) |
|
| 50 | 50 | { |
| 51 | 51 | return $c['response'] |
| 52 | 52 | ->withStatus(500) |
| 53 | 53 | ->withHeader('Content-Type', 'text/html') |
| 54 | 54 | ->write( |
| 55 | - sprintf('Something went wrong! (%s)'."\n", $exception->getMessage()) |
|
| 55 | + sprintf('Something went wrong! (%s)' . "\n", $exception->getMessage()) |
|
| 56 | 56 | ); |
| 57 | 57 | }; |
| 58 | 58 | }; |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | $app = new App($container); |
| 62 | 62 | |
| 63 | 63 | // Set up dependencies |
| 64 | -require __DIR__.'/../config/dependencies.php'; |
|
| 64 | +require __DIR__ . '/../config/dependencies.php'; |
|
| 65 | 65 | // Register middlewares |
| 66 | -require __DIR__.'/../config/middlewares.php'; |
|
| 66 | +require __DIR__ . '/../config/middlewares.php'; |
|
| 67 | 67 | // Register routes |
| 68 | -require __DIR__.'/../config/routes.php'; |
|
| 68 | +require __DIR__ . '/../config/routes.php'; |
|
| 69 | 69 | |
| 70 | 70 | $app->set_logger($container['logger']); |
| 71 | 71 | |
@@ -148,7 +148,7 @@ |
||
| 148 | 148 | * Resolve a string identifier for a given Language. |
| 149 | 149 | * |
| 150 | 150 | * @param LanguageInterface $lang The instance that needs resolution. |
| 151 | - * @param mixed $ident Optional key/index of $config in previous method. |
|
| 151 | + * @param string|null $ident Optional key/index of $config in previous method. |
|
| 152 | 152 | * @throws InvalidArgumentException If the language ident is null. |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (isset($config['languages'])) { |
| 71 | - $available_langs = array_filter($config['languages'], function ($config) { |
|
| 71 | + $available_langs = array_filter($config['languages'], function($config) { |
|
| 72 | 72 | return (!isset($config['active']) || $config['active']); |
| 73 | 73 | }); |
| 74 | 74 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | public static function language_index() |
| 139 | 139 | { |
| 140 | 140 | if (!isset(self::$language_index)) { |
| 141 | - self::$language_index = new GenericConfig(__DIR__.'/../../../../config/languages.json'); |
|
| 141 | + self::$language_index = new GenericConfig(__DIR__ . '/../../../../config/languages.json'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return self::$language_index; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @throws InvalidArgumentException If the language ident is null. |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | - public function resolve_ident(LanguageInterface &$lang, $ident = null) |
|
| 155 | + public function resolve_ident(LanguageInterface & $lang, $ident = null) |
|
| 156 | 156 | { |
| 157 | 157 | if (is_string($ident)) { |
| 158 | 158 | $lang->set_ident($ident); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @param boolean $routable Routable flag, if the object is routable or not. |
| 36 | - * @return RoutableInterface Chainable |
|
| 36 | + * @return RoutableTrait Chainable |
|
| 37 | 37 | */ |
| 38 | 38 | public function set_routable($routable) |
| 39 | 39 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @param mixed $pattern The slug / URL / route pattern (translation string). |
| 54 | - * @return RoutableInterface Chainable |
|
| 54 | + * @return RoutableTrait Chainable |
|
| 55 | 55 | */ |
| 56 | 56 | public function set_slug_pattern($pattern) |
| 57 | 57 | { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @param mixed $slug The slug value (translation string). |
| 72 | - * @return RoutableInterface Chainable |
|
| 72 | + * @return RoutableTrait Chainable |
|
| 73 | 73 | */ |
| 74 | 74 | public function set_slug($slug) |
| 75 | 75 | { |
@@ -49,9 +49,9 @@ |
||
| 49 | 49 | $lock_file = sys_get_temp_dir().'/'.$lock_name; |
| 50 | 50 | $this->lock_fp = fopen($lock_file, 'w'); |
| 51 | 51 | if (!$this->lock_fp) { |
| 52 | - throw new Exception( |
|
| 53 | - 'Can not run action. Lock file not available.' |
|
| 54 | - ); |
|
| 52 | + throw new Exception( |
|
| 53 | + 'Can not run action. Lock file not available.' |
|
| 54 | + ); |
|
| 55 | 55 | } |
| 56 | 56 | if (flock($this->lock_fp, LOCK_EX)) { |
| 57 | 57 | return true; |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | public function start_lock() |
| 47 | 47 | { |
| 48 | 48 | $lock_name = str_replace('\\', '-', get_class($this)); |
| 49 | - $lock_file = sys_get_temp_dir().'/'.$lock_name; |
|
| 49 | + $lock_file = sys_get_temp_dir() . '/' . $lock_name; |
|
| 50 | 50 | $this->lock_fp = fopen($lock_file, 'w'); |
| 51 | 51 | if (!$this->lock_fp) { |
| 52 | 52 | throw new Exception( |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param App $app The template's parent charcoal app instance. |
| 44 | - * @return App Chainable |
|
| 44 | + * @return AbstractTemplate Chainable |
|
| 45 | 45 | */ |
| 46 | 46 | public function set_app(App $app) |
| 47 | 47 | { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * The default Template View is a simple GenericView. |
| 62 | 62 | * |
| 63 | 63 | * @param array $data The data array (as [key=>value] pair) to set. |
| 64 | - * @return AbtractTemplate Chainable |
|
| 64 | + * @return AbstractTemplate Chainable |
|
| 65 | 65 | */ |
| 66 | 66 | public function set_data(array $data) |
| 67 | 67 | { |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | public function set_data(array $data) |
| 123 | 123 | { |
| 124 | 124 | foreach ($data as $prop => $val) { |
| 125 | - $func = [$this, 'set_'.$prop]; |
|
| 125 | + $func = [$this, 'set_' . $prop]; |
|
| 126 | 126 | |
| 127 | 127 | if ($val === null) { |
| 128 | 128 | continue; |