@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | $twigOptions = []; |
48 | 48 | if (!Config::DEV_ENVIRONMENT) { |
49 | 49 | $twigOptions = [ |
50 | - 'cache' => dirname(__DIR__) . '/Cache' |
|
50 | + 'cache' => dirname(__DIR__).'/Cache' |
|
51 | 51 | ]; |
52 | 52 | } |
53 | - $loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views'); |
|
53 | + $loader = new \Twig_Loader_Filesystem(dirname(__DIR__).'/App/Views'); |
|
54 | 54 | $twig = new \Twig_Environment($loader, $twigOptions); |
55 | 55 | |
56 | 56 | return $twig; |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | if ($this->dbh) { |
66 | 66 | return $this->dbh; |
67 | 67 | } |
68 | - $dsn = "mysql:host=" . Config::DB_HOST . ";dbname=" . Config::DB_NAME . ";charset=utf8"; //Creating the Data Source name |
|
68 | + $dsn = "mysql:host=".Config::DB_HOST.";dbname=".Config::DB_NAME.";charset=utf8"; //Creating the Data Source name |
|
69 | 69 | $opt = [ |
70 | 70 | PDO::ATTR_PERSISTENT => true, |
71 | 71 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
72 | 72 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ |
73 | 73 | ]; |
74 | - $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt);; |
|
74 | + $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt); ; |
|
75 | 75 | return $this->dbh; |
76 | 76 | } |
77 | 77 |
@@ -24,8 +24,8 @@ |
||
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | - protected function onlyAdmin(){ |
|
28 | - if(!$this->auth->isAdmin()){ |
|
27 | + protected function onlyAdmin() { |
|
28 | + if (!$this->auth->isAdmin()) { |
|
29 | 29 | $this->alertBox->setAlert("Only admins can access this", 'error'); |
30 | 30 | $this->container->getResponse()->redirect('/admin'); |
31 | 31 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | default: |
24 | 24 | $headerType = 'text/html'; |
25 | 25 | } |
26 | - $contentType = 'Content-Type: ' . $headerType; |
|
26 | + $contentType = 'Content-Type: '.$headerType; |
|
27 | 27 | |
28 | 28 | header($contentType); |
29 | 29 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - header("location: /" . $url); |
|
44 | + header("location: /".$url); |
|
45 | 45 | exit(); //after redirect do not execute anything else from the function |
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -84,25 +84,25 @@ discard block |
||
84 | 84 | //checking for module in namespace, app and core. |
85 | 85 | $childClassNamespace = new \ReflectionClass(get_class($this)); |
86 | 86 | $childClassNamespace = $childClassNamespace->getNamespaceName(); |
87 | - if (class_exists($childClassNamespace . '\\Modules\\' . $loadModule)) { |
|
88 | - $loadModuleObj = $childClassNamespace . '\\' . $loadModule; |
|
89 | - } elseif (class_exists('App\\Modules\\' . $loadModule)) { |
|
90 | - $loadModuleObj = 'App\\Modules\\' . $loadModule; |
|
91 | - } elseif (class_exists('Core\\Modules\\' . $loadModule)) { |
|
92 | - $loadModuleObj = 'Core\\Modules\\' . $loadModule; |
|
93 | - } else { |
|
94 | - throw new \ErrorException('module ' . $loadModule . ' does not exist'); |
|
87 | + if (class_exists($childClassNamespace.'\\Modules\\'.$loadModule)) { |
|
88 | + $loadModuleObj = $childClassNamespace.'\\'.$loadModule; |
|
89 | + } elseif (class_exists('App\\Modules\\'.$loadModule)) { |
|
90 | + $loadModuleObj = 'App\\Modules\\'.$loadModule; |
|
91 | + } elseif (class_exists('Core\\Modules\\'.$loadModule)) { |
|
92 | + $loadModuleObj = 'Core\\Modules\\'.$loadModule; |
|
93 | + }else { |
|
94 | + throw new \ErrorException('module '.$loadModule.' does not exist'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | //Modules must be children of the Module template |
98 | 98 | if (!is_subclass_of($loadModuleObj, 'Core\Modules\Module')) { |
99 | - throw new \ErrorException('Module ' . $loadModuleName . ' must be a sub class of module'); |
|
99 | + throw new \ErrorException('Module '.$loadModuleName.' must be a sub class of module'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $loadedModule = new $loadModuleObj($this->container); |
103 | 103 | //we are not allowed to create public modules, they must be a placeholder ready |
104 | 104 | if (!property_exists($this, $loadModuleName)) { |
105 | - throw new \ErrorException('the protected or private variable of ' . $loadModuleName . ' is not present'); |
|
105 | + throw new \ErrorException('the protected or private variable of '.$loadModuleName.' is not present'); |
|
106 | 106 | } |
107 | 107 | $this->$loadModuleName = $loadedModule; |
108 | 108 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function getView($template) |
129 | 129 | { |
130 | 130 | $twig = $this->container->getTemplate(); |
131 | - return $twig->render($template . '.twig', $this->data); |
|
131 | + return $twig->render($template.'.twig', $this->data); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $this->devHelper(); |
150 | 150 | } |
151 | 151 | $twig = $this->container->getTemplate(); |
152 | - $twig->display($template . '.twig', $this->data); |
|
152 | + $twig->display($template.'.twig', $this->data); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function devHelper($var = '') |