@@ -15,7 +15,7 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * @var ContainerInterface $setting |
| 17 | 17 | * |
| 18 | - */ |
|
| 18 | + */ |
|
| 19 | 19 | public function init() |
| 20 | 20 | { |
| 21 | 21 | $setting = $this->settings['translation']; |
@@ -23,51 +23,51 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - private function _loadkey(string $key , array $replace = []) |
|
| 26 | + private function _loadkey(string $key, array $replace = []) |
|
| 27 | 27 | { |
| 28 | - list($namespace,$group) = explode('.',$key); |
|
| 28 | + list($namespace, $group) = explode('.', $key); |
|
| 29 | 29 | $t_dir = $this->getTranslation_dirs(); |
| 30 | 30 | |
| 31 | - if(in_array($this->local,$t_dir)){ |
|
| 31 | + if (in_array($this->local, $t_dir)) { |
|
| 32 | 32 | |
| 33 | - $translationBaseFolder = $this->settings['translation']['translations_path'].$this->local; |
|
| 34 | - $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; |
|
| 35 | - if(file_exists($translationBaseFile)){ |
|
| 36 | - $lang= include_once ($translationBaseFile); |
|
| 37 | - }else{ |
|
| 33 | + $translationBaseFolder = $this->settings['translation']['translations_path'] . $this->local; |
|
| 34 | + $translationBaseFile = $translationBaseFolder . '/' . $namespace . '.php'; |
|
| 35 | + if (file_exists($translationBaseFile)) { |
|
| 36 | + $lang = include_once ($translationBaseFile); |
|
| 37 | + }else { |
|
| 38 | 38 | return $lang[$group] = $key; |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | - }else{ |
|
| 41 | + }else { |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if(count($replace) > 0){ |
|
| 45 | - foreach($replace as $key=>$replace_item){ |
|
| 46 | - if(strpos($lang[$group],'%') != 0){ |
|
| 47 | - str_replace($key,$replace_item,$lang[$group]); |
|
| 44 | + if (count($replace) > 0) { |
|
| 45 | + foreach ($replace as $key=>$replace_item) { |
|
| 46 | + if (strpos($lang[$group], '%') != 0) { |
|
| 47 | + str_replace($key, $replace_item, $lang[$group]); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | - }else{ |
|
| 51 | - $keyArr = explode('.',$key); |
|
| 50 | + }else { |
|
| 51 | + $keyArr = explode('.', $key); |
|
| 52 | 52 | unset($keyArr[0]); |
| 53 | 53 | $keyArr = array_values($keyArr); |
| 54 | - $lang = $this->getDataFromTranslation($lang,$keyArr); |
|
| 54 | + $lang = $this->getDataFromTranslation($lang, $keyArr); |
|
| 55 | 55 | |
| 56 | 56 | return $lang; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
| 61 | - public function getDataFromTranslation($data,$keyArr){ |
|
| 62 | - $arrayFound = $data[$keyArr[0]]; |
|
| 63 | - if($arrayFound){ |
|
| 61 | + public function getDataFromTranslation($data, $keyArr) { |
|
| 62 | + $arrayFound = $data[$keyArr[0]]; |
|
| 63 | + if ($arrayFound) { |
|
| 64 | 64 | unset($keyArr[0]); |
| 65 | 65 | $keyArr = array_values($keyArr); |
| 66 | - if(isset($keyArr[0])){ |
|
| 67 | - return $this->getDataFromTranslation($arrayFound,$keyArr); |
|
| 66 | + if (isset($keyArr[0])) { |
|
| 67 | + return $this->getDataFromTranslation($arrayFound, $keyArr); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | - return $arrayFound ; |
|
| 70 | + return $arrayFound; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function trans(string $key, array $replace = []) |
| 78 | 78 | { |
| 79 | - return $this->_loadkey($key,$replace); |
|
| 79 | + return $this->_loadkey($key, $replace); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - return array_diff($dir,$ex_folders); |
|
| 91 | + return array_diff($dir, $ex_folders); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; |
| 35 | 35 | if(file_exists($translationBaseFile)){ |
| 36 | 36 | $lang= include_once ($translationBaseFile); |
| 37 | - }else{ |
|
| 37 | + } else{ |
|
| 38 | 38 | return $lang[$group] = $key; |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | - }else{ |
|
| 41 | + } else{ |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | if(count($replace) > 0){ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | str_replace($key,$replace_item,$lang[$group]); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | - }else{ |
|
| 50 | + } else{ |
|
| 51 | 51 | $keyArr = explode('.',$key); |
| 52 | 52 | unset($keyArr[0]); |
| 53 | 53 | $keyArr = array_values($keyArr); |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | return isset($_SESSION['user']); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function attempt(string $username,string $password) |
|
| 27 | + public function attempt(string $username, string $password) |
|
| 28 | 28 | { |
| 29 | 29 | $user = UserDataAccess::getUserLoginField($username)->first(); |
| 30 | 30 | |
| 31 | 31 | if (!$user) { |
| 32 | 32 | return false; |
| 33 | 33 | } |
| 34 | - if (password_verify($password,'')) { |
|
| 34 | + if (password_verify($password, '')) { |
|
| 35 | 35 | $_SESSION['user'] = $user->id; |
| 36 | 36 | return true; |
| 37 | 37 | } |
@@ -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,20 +57,20 @@ 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 | }; |
| 65 | 65 | |
| 66 | 66 | // Register Blade View helper |
| 67 | -$container['view'] = function ($container) { |
|
| 67 | +$container['view'] = function($container) { |
|
| 68 | 68 | |
| 69 | 69 | $messages = $container->flash->getMessages(); |
| 70 | 70 | |
| 71 | 71 | $viewSettings = $container['settings']['view']; |
| 72 | 72 | return new \Slim\Views\Blade( |
| 73 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
| 73 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
| 74 | 74 | $viewSettings['blade_cache_path'], |
| 75 | 75 | null, |
| 76 | 76 | [ |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | $translator = new \Core\Translator\Translator($container); |
| 84 | 84 | $translator->init(); |
| 85 | 85 | |
| 86 | -$container['translator'] = function () use ($translator) { |
|
| 86 | +$container['translator'] = function() use ($translator) { |
|
| 87 | 87 | return $translator; |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | // Register provider |
| 92 | -$container['flash'] = function () { |
|
| 92 | +$container['flash'] = function() { |
|
| 93 | 93 | return new \Slim\Flash\Messages(); |
| 94 | 94 | }; |
| 95 | 95 | |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | /*Dynamic containers in services*/ |
| 107 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
| 107 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
| 108 | 108 | $ex_folders = array('..', '.'); |
| 109 | -$filesInServices = array_diff($dir,$ex_folders); |
|
| 109 | +$filesInServices = array_diff($dir, $ex_folders); |
|
| 110 | 110 | |
| 111 | -foreach($filesInServices as $service){ |
|
| 112 | - $content = preg_replace('/.php/','',$service); |
|
| 113 | - $container[$content] = function () use ($content){ |
|
| 114 | - $class = '\\Core\\Services\\'.$content ; |
|
| 111 | +foreach ($filesInServices as $service) { |
|
| 112 | + $content = preg_replace('/.php/', '', $service); |
|
| 113 | + $container[$content] = function() use ($content){ |
|
| 114 | + $class = '\\Core\\Services\\' . $content; |
|
| 115 | 115 | return new $class(); |
| 116 | 116 | }; |
| 117 | 117 | } |
@@ -1,28 +1,28 @@ |
||
| 1 | 1 | <?php |
| 2 | -define('__APP_ROOT__',__DIR__ . '/../') ; |
|
| 2 | +define('__APP_ROOT__', __DIR__ . '/../'); |
|
| 3 | 3 | |
| 4 | -require __APP_ROOT__.'bootstrap/bootstrap.php'; |
|
| 5 | -require __APP_ROOT__.'core/Functions/helpers.php'; |
|
| 6 | -require __APP_ROOT__.'vendor/autoload.php'; |
|
| 7 | -require __APP_ROOT__.'config/settings.php'; |
|
| 4 | +require __APP_ROOT__ . 'bootstrap/bootstrap.php'; |
|
| 5 | +require __APP_ROOT__ . 'core/Functions/helpers.php'; |
|
| 6 | +require __APP_ROOT__ . 'vendor/autoload.php'; |
|
| 7 | +require __APP_ROOT__ . 'config/settings.php'; |
|
| 8 | 8 | $app = new \Core\App($config); |
| 9 | 9 | |
| 10 | 10 | use SlimFacades\Facade; |
| 11 | 11 | // get container app |
| 12 | -require __APP_ROOT__.'bootstrap/dependencies.php'; |
|
| 13 | -require __APP_ROOT__.'bootstrap/routes.php'; |
|
| 12 | +require __APP_ROOT__ . 'bootstrap/dependencies.php'; |
|
| 13 | +require __APP_ROOT__ . 'bootstrap/routes.php'; |
|
| 14 | 14 | |
| 15 | -if(php_sapi_name() != 'cli') { |
|
| 15 | +if (php_sapi_name() != 'cli') { |
|
| 16 | 16 | $settings['tracy']['path'] = ''; |
| 17 | - if($app->getContainer() instanceof Psr\Container\ContainerInterface){ |
|
| 17 | + if ($app->getContainer() instanceof Psr\Container\ContainerInterface) { |
|
| 18 | 18 | $settings = $app->getContainer()->settings; |
| 19 | - if($settings['debug'] == true){ |
|
| 19 | + if ($settings['debug'] == true) { |
|
| 20 | 20 | Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $settings['tracy']['path']); |
| 21 | 21 | } |
| 22 | 22 | Facade::setFacadeApplication($app); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - require __APP_ROOT__.'bootstrap/middlewares.php'; |
|
| 25 | + require __APP_ROOT__ . 'bootstrap/middlewares.php'; |
|
| 26 | 26 | |
| 27 | 27 | $app->run(); |
| 28 | 28 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | return [ |
| 3 | - 'fields' => [ 'auth'=> ['login' => [ |
|
| 3 | + 'fields' => ['auth'=> ['login' => [ |
|
| 4 | 4 | 'label'=>'afshin' |
| 5 | - ]] ] |
|
| 5 | + ]]] |
|
| 6 | 6 | ]; |
| 7 | 7 | \ No newline at end of file |