@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | class InstallDatabase extends \yii\base\Model |
8 | 8 | { |
9 | - public $name=''; |
|
9 | + public $name = ''; |
|
10 | 10 | public $username; |
11 | 11 | public $password; |
12 | 12 | public $host = 'localhost'; |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | } else { |
55 | 55 | if ($result == InstallHelper::ERROR_DB_UNKNOWN_DATABASE) { |
56 | 56 | // Attempt to create the database (if asked to do so) |
57 | - if ($this->create_database == 1 ) { |
|
58 | - if (! $this->createDatabase($exception)) { |
|
57 | + if ($this->create_database == 1) { |
|
58 | + if (!$this->createDatabase($exception)) { |
|
59 | 59 | $this->error_message = 'cant_create_database'; |
60 | - $this->addError('name', 'Failed to create database "' . $this->name . '" Database error: ' . $exception); |
|
60 | + $this->addError('name', 'Failed to create database "'.$this->name.'" Database error: '.$exception); |
|
61 | 61 | } |
62 | - } else { |
|
62 | + } else { |
|
63 | 63 | // This is useful information - but not an error therefore in |
64 | - if (! $this->isAjaxValidating) { |
|
64 | + if (!$this->isAjaxValidating) { |
|
65 | 65 | $this->error_message = 'unknown_database'; |
66 | - $this->addError('name', 'Unknown database name "' . $this->name . '"'); |
|
66 | + $this->addError('name', 'Unknown database name "'.$this->name.'"'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } else if ($result == InstallHelper::ERROR_DB_UNKNOWN_HOST) { |
70 | 70 | $this->error_message = 'unknown_host'; |
71 | - $this->addError('host', 'Unknown host name "' . $this->host . '"'); |
|
71 | + $this->addError('host', 'Unknown host name "'.$this->host.'"'); |
|
72 | 72 | } else if ($result == InstallHelper::ERROR_DB_ACCESS_DENIED) { |
73 | 73 | $this->error_message = 'access_denied'; |
74 | 74 | $this->addError('username', 'The username either does not exist or does not work with the given password'); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $config['dsn'] = 'mysql:host='.$this->host.';'; |
93 | 93 | $connection = new \neon\core\db\Connection($config); |
94 | 94 | try { |
95 | - $connection->createCommand('CREATE DATABASE ' . $this->name)->execute(); |
|
95 | + $connection->createCommand('CREATE DATABASE '.$this->name)->execute(); |
|
96 | 96 | } catch (\yii\db\Exception $e) { |
97 | 97 | // could not create the database |
98 | 98 | $exception = $e->getMessage(); |
@@ -137,7 +137,7 @@ |
||
137 | 137 | */ |
138 | 138 | protected function getTo(Swift_Mime_SimpleMessage $message) |
139 | 139 | { |
140 | - return collect($this->allContacts($message))->map(function ($display, $address) { |
|
140 | + return collect($this->allContacts($message))->map(function($display, $address) { |
|
141 | 141 | return $display ? $display." <{$address}>" : $address; |
142 | 142 | })->values()->implode(','); |
143 | 143 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | // 'theme.css', |
21 | 21 | 'https://fonts.googleapis.com/css?family=Nunito+Sans:200,200i,300,300i,400,400i,600,600i,700,700i,800,900', |
22 | 22 | ]; |
23 | - public $sourcePath = __DIR__ . '/assets'; |
|
23 | + public $sourcePath = __DIR__.'/assets'; |
|
24 | 24 | public $depends = [ |
25 | 25 | // '\neon\core\assets\CoreAsset', |
26 | 26 | // '\yii\bootstrap\BootstrapAsset', |
@@ -29,6 +29,6 @@ discard block |
||
29 | 29 | public function init() |
30 | 30 | { |
31 | 31 | $info = neon()->assetManager->publish($this->sourcePath, $this->publishOptions); |
32 | - neon()->view->registerJs('var NEON_THEME_URL = "' . $info[1] . '";', View::POS_HEAD, 'neonThemeData'); |
|
32 | + neon()->view->registerJs('var NEON_THEME_URL = "'.$info[1].'";', View::POS_HEAD, 'neonThemeData'); |
|
33 | 33 | } |
34 | 34 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | * @param string $file - the path to the config file |
57 | 57 | * @throws \Exception - if the environment variable value is an array |
58 | 58 | */ |
59 | - public static function setEnvironmentFromFile($file, $overwrite=false) |
|
59 | + public static function setEnvironmentFromFile($file, $overwrite = false) |
|
60 | 60 | { |
61 | 61 | if (file_exists($file)) { |
62 | 62 | // we need to load in the locally set environment ini file |
63 | 63 | $iniSettings = parse_ini_file($file, false, INI_SCANNER_TYPED); |
64 | - foreach($iniSettings as $name => $value) { |
|
64 | + foreach ($iniSettings as $name => $value) { |
|
65 | 65 | Env::setEnvironmentVariable($name, $value, $overwrite); |
66 | 66 | } |
67 | 67 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param bool $overwrite Whether to force overwriting the environment variable if it already exists defaults to false |
76 | 76 | * @throws \Exception - if the environment variable value is an array |
77 | 77 | */ |
78 | - public static function setEnvironmentVariable($key, $value, $overwrite=false) |
|
78 | + public static function setEnvironmentVariable($key, $value, $overwrite = false) |
|
79 | 79 | { |
80 | 80 | if (is_array($value)) { |
81 | 81 | throw new \Exception('Environment variables do not support nesting. The variable "'.print_r($key, true).'" is poop.'); |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | throw new \Exception('DIR_ROOT constant must be defined as the path to the root of your neon application'); |
110 | 110 | } |
111 | 111 | |
112 | - defined('DIR_CONFIG') || define('DIR_CONFIG', DIR_ROOT . '/config'); |
|
113 | - defined('DIR_VAR') || define('DIR_VAR', DIR_ROOT . '/var'); |
|
114 | - defined('DIR_SYSTEM') || define('DIR_SYSTEM', DIR_ROOT . '/system'); |
|
115 | - defined('DIR_PUBLIC') || define('DIR_PUBLIC', DIR_ROOT . '/public'); |
|
112 | + defined('DIR_CONFIG') || define('DIR_CONFIG', DIR_ROOT.'/config'); |
|
113 | + defined('DIR_VAR') || define('DIR_VAR', DIR_ROOT.'/var'); |
|
114 | + defined('DIR_SYSTEM') || define('DIR_SYSTEM', DIR_ROOT.'/system'); |
|
115 | + defined('DIR_PUBLIC') || define('DIR_PUBLIC', DIR_ROOT.'/public'); |
|
116 | 116 | |
117 | 117 | Env::environment(); |
118 | 118 | if (!class_exists('Neon')) |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $name |
160 | 160 | * @param boolean $saveToEnvFile |
161 | 161 | */ |
162 | - private static function createEnvironmentVariable($name, $saveToEnvFile=true) |
|
162 | + private static function createEnvironmentVariable($name, $saveToEnvFile = true) |
|
163 | 163 | { |
164 | 164 | $value = Hash::uuid64().Hash::uuid64().Hash::uuid64().Hash::uuid64(); |
165 | 165 | if ($saveToEnvFile && file_exists(DIR_CONFIG.'/env.ini')) |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | * @param string $separator the section separator for the uuid - normally '-' |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public static function uuid($separator='-') |
|
29 | + public static function uuid($separator = '-') |
|
30 | 30 | { |
31 | - $sha = sha1(uniqid('', true).rand(1000000,9999999)); |
|
32 | - return substr($sha,0,8).$separator.substr($sha,9,4).$separator.'3'.substr($sha,15,3).$separator.'8'.substr($sha,19,3).$separator.substr($sha,22,12); |
|
31 | + $sha = sha1(uniqid('', true).rand(1000000, 9999999)); |
|
32 | + return substr($sha, 0, 8).$separator.substr($sha, 9, 4).$separator.'3'.substr($sha, 15, 3).$separator.'8'.substr($sha, 19, 3).$separator.substr($sha, 22, 12); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string encoding - characters used for the encoding |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public static function uuid64($encoding='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-') |
|
40 | + public static function uuid64($encoding = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-') |
|
41 | 41 | { |
42 | 42 | $uuid = self::uuid(''); // create a uuid without any '-' in it |
43 | 43 | return self::uuid2uuid64($uuid, $encoding); |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | * @param string encoding - characters used for the encoding |
60 | 60 | * @return string |
61 | 61 | */ |
62 | - public static function uuid2uuid64($uuid, $encoding='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-') |
|
62 | + public static function uuid2uuid64($uuid, $encoding = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-') |
|
63 | 63 | { |
64 | - if (strlen($uuid)==22) |
|
64 | + if (strlen($uuid) == 22) |
|
65 | 65 | return $uuid; |
66 | 66 | |
67 | 67 | // remove any hyphens |
68 | - $uuid = str_replace('-','',$uuid); |
|
68 | + $uuid = str_replace('-', '', $uuid); |
|
69 | 69 | |
70 | 70 | $uuid .= '0'; // 33 hexadecimal characters = 22 64-cimal chars. |
71 | 71 | // to convert from base-16 to base-64 (not Base64) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | while ($position < 33) { |
76 | 76 | $snip = substr($uuid, $position, 3); |
77 | 77 | $number = hexdec($snip); |
78 | - $uuid64 .= $encoding[(integer)floor($number/64)].$encoding[(integer)($number%64)]; |
|
78 | + $uuid64 .= $encoding[(integer) floor($number / 64)].$encoding[(integer) ($number % 64)]; |
|
79 | 79 | $position += 3; |
80 | 80 | } |
81 | 81 | return $uuid64; |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @return string token |
97 | 97 | * @throws \ReflectionException |
98 | 98 | */ |
99 | - public static function setObjectToToken($object, $duration=86400) |
|
99 | + public static function setObjectToToken($object, $duration = 86400) |
|
100 | 100 | { |
101 | 101 | // get public properties of child class |
102 | 102 | $data = \Neon::getObjectVars($object); |
103 | 103 | $data['class'] = get_class($object); |
104 | 104 | if (method_exists($object, 'toArray')) |
105 | 105 | $data = array_merge($data, $object->toArray(['objectToken'])); |
106 | - $token = sha1(serialize($data) . env('NEON_SECRET')); |
|
106 | + $token = sha1(serialize($data).env('NEON_SECRET')); |
|
107 | 107 | neon()->cache->set($token, $data, $duration); // 24 hour |
108 | 108 | return neon()->security->maskToken($token); |
109 | 109 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @throws BadRequestHttpException |
117 | 117 | * @throws NotFoundHttpException |
118 | 118 | */ |
119 | - public static function getObjectFromToken($token, $expectClass=null) |
|
119 | + public static function getObjectFromToken($token, $expectClass = null) |
|
120 | 120 | { |
121 | 121 | $data = neon()->cache->get(neon()->security->unmaskToken($token)); |
122 | 122 | if ($data === null) |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // If we have requested json we should return the error as json |
34 | 34 | $acceptsJson = array_key_exists('application/json', neon()->request->getAcceptableContentTypes()); |
35 | - if (neon()->request->getIsAjax() || $acceptsJson ) { |
|
35 | + if (neon()->request->getIsAjax() || $acceptsJson) { |
|
36 | 36 | return $data; |
37 | 37 | } |
38 | 38 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return $this->render($errorPage, $data); |
58 | 58 | } |
59 | 59 | // Look up specific framework view file e.g `core/view/error_404.php` |
60 | - $viewForError = 'error_' . $data['status']; |
|
60 | + $viewForError = 'error_'.$data['status']; |
|
61 | 61 | if ($this->findView($viewForError)) { |
62 | 62 | return $this->render($viewForError, $data); |
63 | 63 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getCustomErrorPage($errorCode) |
74 | 74 | { |
75 | - $themeFileOld = neon('cms')->getThemeAlias() . "/error_$errorCode.tpl"; |
|
76 | - $themeFile = neon('cms')->getThemeAlias() . "/pages/errors/$errorCode.tpl"; |
|
75 | + $themeFileOld = neon('cms')->getThemeAlias()."/error_$errorCode.tpl"; |
|
76 | + $themeFile = neon('cms')->getThemeAlias()."/pages/errors/$errorCode.tpl"; |
|
77 | 77 | if ($this->findView($themeFile)) { |
78 | 78 | return $themeFile; |
79 | 79 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $class = \get_class($this); |
67 | 67 | if (($pos = strrpos($class, '\\')) !== false) { |
68 | 68 | $controllers = neon()->isConsoleApp() ? 'console' : 'controllers'; |
69 | - $this->controllerNamespace = substr($class, 0, $pos) . '\\' . $controllers; |
|
69 | + $this->controllerNamespace = substr($class, 0, $pos).'\\'.$controllers; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | parent::init(); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param boolean $refresh - default false |
147 | 147 | * @return type |
148 | 148 | */ |
149 | - public function getSetting($name, $default=null, $refresh=false) |
|
149 | + public function getSetting($name, $default = null, $refresh = false) |
|
150 | 150 | { |
151 | 151 | $settingManager = neon()->settingsManager; |
152 | 152 | return $settingManager->get($this->id, $name, $default, $refresh); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * @inheritdoc |
188 | 188 | */ |
189 | - public function uninstall(){} |
|
189 | + public function uninstall() {} |
|
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Get the alias key to this module (App) |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function getClassAlias() |
198 | 198 | { |
199 | - return '@' . rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/"); |
|
199 | + return '@'.rtrim(str_replace(['\\', 'App'], ['/', ''], get_called_class()), "/"); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function getAssetsPath() |
235 | 235 | { |
236 | - return $this->getPath() . '/assets'; |
|
236 | + return $this->getPath().'/assets'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function getDocsPath() |
243 | 243 | { |
244 | - return $this->getPath() . '/docs'; |
|
244 | + return $this->getPath().'/docs'; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | public function getDataMapProviders() |
268 | 268 | { |
269 | 269 | $availableMaps = []; |
270 | - foreach(neon()->getAllApps() as $name => $config) { |
|
270 | + foreach (neon()->getAllApps() as $name => $config) { |
|
271 | 271 | $app = neon($name); |
272 | 272 | if ($app instanceof IDataMapProvider) { |
273 | 273 | $maps = $app->getDataMapTypes(); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | if ($provider === null) { |
294 | 294 | throw new \Exception("The map provider '$name' specified can not be found."); |
295 | 295 | } |
296 | - if (! $provider instanceof IDataMapProvider) { |
|
296 | + if (!$provider instanceof IDataMapProvider) { |
|
297 | 297 | throw new \Exception("The Provider '$name' must implement the 'neon\\core\\interfaces\\IDataMapProvider' interface."); |
298 | 298 | } |
299 | 299 | return $provider; |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | * @param string $instanceOf - a string defining a class or interface that the ckasses must implement or be |
340 | 340 | * @return array |
341 | 341 | */ |
342 | - public function getClasses($subPath='', $instanceOf=false) |
|
342 | + public function getClasses($subPath = '', $instanceOf = false) |
|
343 | 343 | { |
344 | 344 | $path = $this->getPath().Str::start($subPath, '/'); |
345 | 345 | $classes = []; |
346 | 346 | if (!file_exists($path)) return []; |
347 | - foreach(\neon\core\helpers\File::findFiles("$path", ['only' => ['*.php']]) as $file) { |
|
347 | + foreach (\neon\core\helpers\File::findFiles("$path", ['only' => ['*.php']]) as $file) { |
|
348 | 348 | $class = $this->getClassFromFile($file); |
349 | 349 | // the class is not valid then skip |
350 | 350 | if (!$class) continue; |
@@ -107,7 +107,7 @@ |
||
107 | 107 | $prefixedConditions = []; |
108 | 108 | foreach ($conditions as $columnName => $columnValue) { |
109 | 109 | if (strpos($columnName, '(') === false) { |
110 | - $columnName = preg_replace('/^' . preg_quote($alias) . '\.(.*)$/', '$1', $columnName); |
|
110 | + $columnName = preg_replace('/^'.preg_quote($alias).'\.(.*)$/', '$1', $columnName); |
|
111 | 111 | if (strpos($columnName, '[[') === 0) { |
112 | 112 | $prefixedColumn = "{$alias}.{$columnName}"; |
113 | 113 | } else { |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | $bits = explode(':', $timeString); |
57 | 57 | return [ |
58 | - 'hh' => Arr::get($bits,0, '00'), |
|
59 | - 'mm' => Arr::get($bits,1, '00'), |
|
60 | - 'ss' => Arr::get($bits,2, '00') |
|
58 | + 'hh' => Arr::get($bits, 0, '00'), |
|
59 | + 'mm' => Arr::get($bits, 1, '00'), |
|
60 | + 'ss' => Arr::get($bits, 2, '00') |
|
61 | 61 | ]; |
62 | 62 | } |
63 | 63 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /** |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function getValueDisplay($context='') |
|
110 | + public function getValueDisplay($context = '') |
|
111 | 111 | { |
112 | 112 | // don't show seconds if they are not to be set |
113 | 113 | return neon()->formatter->asTime($this->getValue()); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * @inheritdoc |
127 | 127 | */ |
128 | - public function processAsFilter(IQuery $query, $searchData=null) |
|
128 | + public function processAsFilter(IQuery $query, $searchData = null) |
|
129 | 129 | { |
130 | 130 | $searchData = ($searchData === null) ? $this->getValue() : $searchData; |
131 | 131 | if (!empty($searchData)) { |