@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | /* database connection */ |
7 | 7 | |
8 | 8 | |
9 | -$container['db'] = function ($container) { |
|
9 | +$container['db'] = function($container) { |
|
10 | 10 | $db = $container['settings']['db']; |
11 | 11 | $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'], |
12 | 12 | $db['username'], $db['password']); |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | // |
19 | 19 | |
20 | 20 | |
21 | -$container['generalErrorHandler'] = function ($container) { |
|
21 | +$container['generalErrorHandler'] = function($container) { |
|
22 | 22 | return new \Core\Handlers\GeneralErrorHandler($container); |
23 | 23 | }; |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | 27 | // Service factory for the ORM |
28 | -$container['validator'] = function () { |
|
28 | +$container['validator'] = function() { |
|
29 | 29 | return new App\Validation\Validator(); |
30 | 30 | }; |
31 | 31 | |
32 | 32 | |
33 | -$container['eloquent'] = function ($container) { |
|
33 | +$container['eloquent'] = function($container) { |
|
34 | 34 | $capsule = new \Illuminate\Database\Capsule\Manager; |
35 | 35 | $capsule->addConnection($container['settings']['db']); |
36 | 36 | $capsule->setAsGlobal(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | // monolog |
51 | -$container['logger'] = function ($c) { |
|
51 | +$container['logger'] = function($c) { |
|
52 | 52 | $settings = $c->get('settings')['logger']; |
53 | 53 | $logger = new Monolog\Logger($settings['name']); |
54 | 54 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | }; |
58 | 58 | |
59 | 59 | // not found handler |
60 | -$container['notFoundHandler'] = function ($container) { |
|
61 | - return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
60 | +$container['notFoundHandler'] = function($container) { |
|
61 | + return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
62 | 62 | return $container['view']->render($response->withStatus(404), '404'); |
63 | 63 | }; |
64 | 64 | }; |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | $translator = new \Core\Translator\Translator($container); |
69 | 69 | $translator->init(); |
70 | 70 | |
71 | -$container['translator'] = function () use ($translator) { |
|
71 | +$container['translator'] = function() use ($translator) { |
|
72 | 72 | return $translator; |
73 | 73 | }; |
74 | 74 | |
75 | 75 | |
76 | 76 | // Register provider |
77 | -$container['flash'] = function () { |
|
77 | +$container['flash'] = function() { |
|
78 | 78 | return new \Slim\Flash\Messages(); |
79 | 79 | }; |
80 | 80 | |
@@ -90,20 +90,20 @@ discard block |
||
90 | 90 | $setting_session_driver = $container['settings']['session']['driver'] ?? 'session'; |
91 | 91 | |
92 | 92 | $sessionOBJ = new \Core\Services\Session($setting_session_driver); |
93 | -$session = $sessionOBJ->init('session') ; |
|
93 | +$session = $sessionOBJ->init('session'); |
|
94 | 94 | |
95 | -$session->set('afshin.test.tes','yes'); |
|
95 | +$session->set('afshin.test.tes', 'yes'); |
|
96 | 96 | dd($session->get('afshin.test.tes')); |
97 | 97 | |
98 | 98 | |
99 | 99 | // Register Blade View helper |
100 | -$container['view'] = function ($container) { |
|
100 | +$container['view'] = function($container) { |
|
101 | 101 | $messages = $container->flash->getMessages(); |
102 | 102 | |
103 | 103 | $viewSettings = $container['settings']['view']; |
104 | 104 | |
105 | 105 | return new \Slim\Views\Blade( |
106 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
106 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
107 | 107 | $viewSettings['blade_cache_path'], |
108 | 108 | null, |
109 | 109 | [ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ] |
114 | 114 | ); |
115 | 115 | }; |
116 | -$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){ |
|
116 | +$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() { |
|
117 | 117 | |
118 | 118 | return "<?php echo 'Hello Directive'; ?>"; |
119 | 119 | }); |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | /*Dynamic containers in services*/ |
130 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
130 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
131 | 131 | $ex_folders = array('..', '.'); |
132 | -$filesInServices = array_diff($dir,$ex_folders); |
|
132 | +$filesInServices = array_diff($dir, $ex_folders); |
|
133 | 133 | |
134 | -foreach($filesInServices as $service){ |
|
135 | - $content = preg_replace('/.php/','',$service); |
|
136 | - $container[$content] = function () use ($content){ |
|
137 | - $class = '\\Core\\Services\\'.$content ; |
|
134 | +foreach ($filesInServices as $service) { |
|
135 | + $content = preg_replace('/.php/', '', $service); |
|
136 | + $container[$content] = function() use ($content){ |
|
137 | + $class = '\\Core\\Services\\' . $content; |
|
138 | 138 | return new $class(); |
139 | 139 | }; |
140 | 140 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | class AbstractSession |
13 | 13 | { |
14 | 14 | |
15 | - public function getRecursiveSessionKey($data , $keyArr){ |
|
15 | + public function getRecursiveSessionKey($data , $keyArr){ |
|
16 | 16 | $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
17 | 17 | if($arrayFound){ |
18 | 18 | unset($keyArr[0]); |
@@ -12,16 +12,16 @@ discard block |
||
12 | 12 | class AbstractSession |
13 | 13 | { |
14 | 14 | |
15 | - public function getRecursiveSessionKey($data , $keyArr){ |
|
16 | - $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
17 | - if($arrayFound){ |
|
15 | + public function getRecursiveSessionKey($data, $keyArr) { |
|
16 | + $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
17 | + if ($arrayFound) { |
|
18 | 18 | unset($keyArr[0]); |
19 | 19 | $keyArr = array_values($keyArr); |
20 | - if(isset($keyArr[0])){ |
|
21 | - return $this->getRecursiveSessionKey($arrayFound,$keyArr); |
|
20 | + if (isset($keyArr[0])) { |
|
21 | + return $this->getRecursiveSessionKey($arrayFound, $keyArr); |
|
22 | 22 | } |
23 | 23 | } |
24 | - return $arrayFound ; |
|
24 | + return $arrayFound; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $sourceRef = &$source; |
34 | 34 | } |
35 | 35 | $keyName = trim($keyName); |
36 | - $sourceRef = &$sourceRef[$keyName]; |
|
36 | + $sourceRef = &$sourceRef[$keyName]; |
|
37 | 37 | } |
38 | 38 | $sourceRef = $value; |
39 | 39 | unset($sourceRef); |
@@ -34,12 +34,12 @@ |
||
34 | 34 | |
35 | 35 | public function exists($key,$val) |
36 | 36 | { |
37 | - $keySession = $this->get($key); |
|
37 | + $keySession = $this->get($key); |
|
38 | 38 | |
39 | - if($keySession){ |
|
40 | - return true; |
|
41 | - } |
|
42 | - return false; |
|
39 | + if($keySession){ |
|
40 | + return true; |
|
41 | + } |
|
42 | + return false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 |
@@ -15,28 +15,28 @@ |
||
15 | 15 | { |
16 | 16 | public function get($key = null) |
17 | 17 | { |
18 | - if(!isset($_SESSION)) return []; |
|
18 | + if (!isset($_SESSION)) return []; |
|
19 | 19 | |
20 | - if(!$key){ |
|
20 | + if (!$key) { |
|
21 | 21 | return $_SESSION; |
22 | - }else{ |
|
23 | - $keys = explode('.',$key); |
|
24 | - $sessionVal = $this->getRecursiveSessionKey($_SESSION,$keys); |
|
22 | + }else { |
|
23 | + $keys = explode('.', $key); |
|
24 | + $sessionVal = $this->getRecursiveSessionKey($_SESSION, $keys); |
|
25 | 25 | return $sessionVal; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - public function set($key,$val) |
|
29 | + public function set($key, $val) |
|
30 | 30 | { |
31 | - $_SESSION = $this->setArr($key,$val); |
|
31 | + $_SESSION = $this->setArr($key, $val); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | - public function exists($key,$val) |
|
35 | + public function exists($key, $val) |
|
36 | 36 | { |
37 | 37 | $keySession = $this->get($key); |
38 | 38 | |
39 | - if($keySession){ |
|
39 | + if ($keySession) { |
|
40 | 40 | return true; |
41 | 41 | } |
42 | 42 | return false; |