@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public static function maxUploadSize() |
| 27 | 27 | { |
| 28 | - $postMax = Str::toBytes(ini_get('post_max_size')); |
|
| 28 | + $postMax = Str::toBytes(ini_get('post_max_size')); |
|
| 29 | 29 | $uploadMax = Str::toBytes(ini_get('upload_max_filesize')); |
| 30 | 30 | return min($postMax, $uploadMax); |
| 31 | 31 | } |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * @param bool $scheme - whether to add the http / https scheme |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public static function baseUrl($url, $scheme=false) |
|
| 34 | + public static function baseUrl($url, $scheme = false) |
|
| 35 | 35 | { |
| 36 | - return self::base($scheme) . '/' . ltrim($url, '/'); |
|
| 36 | + return self::base($scheme).'/'.ltrim($url, '/'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | * @param type $scheme |
| 43 | 43 | * @return type |
| 44 | 44 | */ |
| 45 | - public static function getPageUrl($pageId, $scheme=false) |
|
| 45 | + public static function getPageUrl($pageId, $scheme = false) |
|
| 46 | 46 | { |
| 47 | - return self::base($scheme) . neon('cms')->page->getUrlOfPage($pageId); |
|
| 47 | + return self::base($scheme).neon('cms')->page->getUrlOfPage($pageId); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -58,18 +58,18 @@ discard block |
||
| 58 | 58 | * @return boolean |
| 59 | 59 | * @deprected use neon()->request->isRoute(); which copes with unlimited nesting and wilcard patterns as well as param matching |
| 60 | 60 | */ |
| 61 | - public static function isRoute($route, $currentUrl=false) |
|
| 61 | + public static function isRoute($route, $currentUrl = false) |
|
| 62 | 62 | { |
| 63 | 63 | // deprecated('\neon\core\helpers\Url::isRoute', 'Please use neon()->request->isRoute() which copes with unlimited nesting and wilcard patterns as well as param matching'); |
| 64 | 64 | $r = explode('/', trim($route, '/')); |
| 65 | 65 | $currentUrl ? $currentUrl : \Neon::$app->controller->getRoute(); |
| 66 | - $currentRoute = explode('/', trim($currentUrl,'/')); |
|
| 66 | + $currentRoute = explode('/', trim($currentUrl, '/')); |
|
| 67 | 67 | |
| 68 | 68 | $m = Arr::getValue($currentRoute, 0); // module |
| 69 | 69 | $c = Arr::getValue($currentRoute, 1); // controller |
| 70 | 70 | $a = Arr::getValue($currentRoute, 2); // action |
| 71 | 71 | |
| 72 | - switch(count($r)){ |
|
| 72 | + switch (count($r)) { |
|
| 73 | 73 | case 1: |
| 74 | 74 | // match just module |
| 75 | 75 | return $r[0] == $m; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return ($r[0] == $m && $r[1] == $c); |
| 79 | 79 | case 3: |
| 80 | 80 | // match the module / controller /action |
| 81 | - return ($r[0] == $m && $r[1] == $c && $r[2] == $a) ; |
|
| 81 | + return ($r[0] == $m && $r[1] == $c && $r[2] == $a); |
|
| 82 | 82 | } |
| 83 | 83 | return false; |
| 84 | 84 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | // if an array is passed in it will get nested one level because of the spread operator |
| 109 | 109 | if (is_array($urls[0])) $urls = $urls[0]; |
| 110 | 110 | $currentUrl = neon()->request->getPathInfo(); |
| 111 | - foreach($urls as $url) { |
|
| 111 | + foreach ($urls as $url) { |
|
| 112 | 112 | $url = str_replace(Url::base(), '', $url); |
| 113 | 113 | if ($currentUrl !== '' && ltrim($url, '/') === $currentUrl) { |
| 114 | 114 | return true; |
@@ -106,7 +106,9 @@ |
||
| 106 | 106 | public static function isUrl(...$urls) |
| 107 | 107 | { |
| 108 | 108 | // if an array is passed in it will get nested one level because of the spread operator |
| 109 | - if (is_array($urls[0])) $urls = $urls[0]; |
|
| 109 | + if (is_array($urls[0])) { |
|
| 110 | + $urls = $urls[0]; |
|
| 111 | + } |
|
| 110 | 112 | $currentUrl = neon()->request->getPathInfo(); |
| 111 | 113 | foreach($urls as $url) { |
| 112 | 114 | $url = str_replace(Url::base(), '', $url); |
@@ -175,9 +175,9 @@ |
||
| 175 | 175 | ]); |
| 176 | 176 | } |
| 177 | 177 | if ($userItems) { |
| 178 | - $out .= \yii\widgets\Menu::widget([ |
|
| 179 | - // this is the old code to use the yii/bootstrap extension |
|
| 180 | - // it becomes very hard to remove bootstrap if we use these. |
|
| 178 | + $out .= \yii\widgets\Menu::widget([ |
|
| 179 | + // this is the old code to use the yii/bootstrap extension |
|
| 180 | + // it becomes very hard to remove bootstrap if we use these. |
|
| 181 | 181 | 'options'=> ['class' => 'navbar-nav navbar-right nav'], |
| 182 | 182 | 'items'=> $userItems['items'] |
| 183 | 183 | ]); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | 'load' => View::POS_LOAD, |
| 60 | 60 | ]; |
| 61 | 61 | if (!array_key_exists($position, $positions)) { |
| 62 | - throw new \Exception('The javascript position specified must be one of ' . print_r(array_keys($positions)) . ', you specified "'.$position.'"'); |
|
| 62 | + throw new \Exception('The javascript position specified must be one of '.print_r(array_keys($positions)).', you specified "'.$position.'"'); |
|
| 63 | 63 | } |
| 64 | 64 | Js::begin(['position' => $positions[$position]]); |
| 65 | 65 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param string $image - url |
| 117 | 117 | * @return string |
| 118 | 118 | */ |
| 119 | - public static function userMenuCard($name=null, $email=null, $image=null) |
|
| 119 | + public static function userMenuCard($name = null, $email = null, $image = null) |
|
| 120 | 120 | { |
| 121 | 121 | if ($name == null && $email == null && $image == null) { |
| 122 | 122 | $u = neon()->user; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | static::getMenuManager()->add('user', [ |
| 142 | 142 | 'template' => '<a href="{url}" class="dropdown-toggle navbarUserDropdown" data-toggle="dropdown">{label}</a>', |
| 143 | 143 | 'options' => ['class'=>'dropdown navbarUserDropdown'], |
| 144 | - 'label' => neon()->user->isGuest ? 'Guest' : '<img class="nav-avatar avatar" src="' . neon()->user->getImageUrl(30) . '"/> ' . neon()->user->getName(), |
|
| 144 | + 'label' => neon()->user->isGuest ? 'Guest' : '<img class="nav-avatar avatar" src="'.neon()->user->getImageUrl(30).'"/> '.neon()->user->getName(), |
|
| 145 | 145 | 'url' => ['/user/account/index'], |
| 146 | 146 | 'linkOptions' => ['class' => 'navbarUserDropdown'], |
| 147 | 147 | 'encode' => false, |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | //['label' => '<i class="fa fa-cog" aria-hidden="true"></i> My Account', 'url' => ['/user/account/index'], 'encode'=>false ], |
| 155 | 155 | //'<li class="divider"></li>', |
| 156 | - ['label' => '<i class="fa fa-sign-out" aria-hidden="true"></i> Log Out', 'url' => ['/user/account/logout'], 'encode'=>false ] |
|
| 156 | + ['label' => '<i class="fa fa-sign-out" aria-hidden="true"></i> Log Out', 'url' => ['/user/account/logout'], 'encode'=>false] |
|
| 157 | 157 | ] |
| 158 | 158 | ]); |
| 159 | 159 | $adminItems = static::getMenuManager()->getMainAdminMenu(); |
| 160 | - foreach($adminItems as $key => $items) { |
|
| 161 | - foreach($items as $key2 => $item) { |
|
| 160 | + foreach ($adminItems as $key => $items) { |
|
| 161 | + foreach ($items as $key2 => $item) { |
|
| 162 | 162 | if (isset($item['visible'])) { |
| 163 | 163 | $adminItems[$key][$key2]['visible'] = value($item['visible']); |
| 164 | 164 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param string $type - one of 'date' | 'datetime' | 'time' |
| 28 | 28 | * @return null|string date in format defined by $toFormat |
| 29 | 29 | */ |
| 30 | - public static function convertDate($date, $fromFormat, $toFormat, $type='date') |
|
| 30 | + public static function convertDate($date, $fromFormat, $toFormat, $type = 'date') |
|
| 31 | 31 | { |
| 32 | 32 | $date = \DateTime::createFromFormat(self::convertDateFormatToPhp($fromFormat), $date); |
| 33 | 33 | return is_bool($date) ? null : $date->format(self::convertDateFormatToPhp($toFormat, $type)); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param string $type - one of 'date' | 'datetime' | 'time' |
| 64 | 64 | * @return string - string representing a php date format |
| 65 | 65 | */ |
| 66 | - public static function convertDateFormatToPhp($format, $type='date') |
|
| 66 | + public static function convertDateFormatToPhp($format, $type = 'date') |
|
| 67 | 67 | { |
| 68 | 68 | if (strncmp($format, 'php:', 4) === 0) |
| 69 | 69 | return substr($format, 4); |
@@ -47,10 +47,12 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public static function convertDateFormatToJui($format) |
| 49 | 49 | { |
| 50 | - if (strncmp($format, 'php:', 4) === 0) |
|
| 51 | - return self::convertDatePhpToJui(substr($format, 4)); |
|
| 52 | - if (strncmp($format, 'icu:', 4) === 0) |
|
| 53 | - return self::convertDateIcuToJui(substr($format, 4)); |
|
| 50 | + if (strncmp($format, 'php:', 4) === 0) { |
|
| 51 | + return self::convertDatePhpToJui(substr($format, 4)); |
|
| 52 | + } |
|
| 53 | + if (strncmp($format, 'icu:', 4) === 0) { |
|
| 54 | + return self::convertDateIcuToJui(substr($format, 4)); |
|
| 55 | + } |
|
| 54 | 56 | return self::convertDateIcuToJui($format); |
| 55 | 57 | } |
| 56 | 58 | |
@@ -65,10 +67,12 @@ discard block |
||
| 65 | 67 | */ |
| 66 | 68 | public static function convertDateFormatToPhp($format, $type='date') |
| 67 | 69 | { |
| 68 | - if (strncmp($format, 'php:', 4) === 0) |
|
| 69 | - return substr($format, 4); |
|
| 70 | - if (strncmp($format, 'icu:', 4) === 0) |
|
| 71 | - return self::convertDateIcuToPhp(substr($format, 4), $type); |
|
| 70 | + if (strncmp($format, 'php:', 4) === 0) { |
|
| 71 | + return substr($format, 4); |
|
| 72 | + } |
|
| 73 | + if (strncmp($format, 'icu:', 4) === 0) { |
|
| 74 | + return self::convertDateIcuToPhp(substr($format, 4), $type); |
|
| 75 | + } |
|
| 72 | 76 | // assume icu format by default - this is the default used by neon()->formatter->dateFormat |
| 73 | 77 | return self::convertDateIcuToPhp($format, $type); |
| 74 | 78 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | return static::$snakeCache[$key][$delimiter]; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if (! ctype_lower($value)) { |
|
| 205 | + if (!ctype_lower($value)) { |
|
| 206 | 206 | $value = preg_replace('/\s+/u', '', $value); |
| 207 | 207 | |
| 208 | 208 | $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value)); |
@@ -343,8 +343,7 @@ discard block |
||
| 343 | 343 | public static function replaceFirst($search, $replace, $subject) |
| 344 | 344 | { |
| 345 | 345 | $position = strpos($subject, $search); |
| 346 | - return $position === false ? $subject : |
|
| 347 | - substr_replace($subject, $replace, $position, strlen($search)); |
|
| 346 | + return $position === false ? $subject : substr_replace($subject, $replace, $position, strlen($search)); |
|
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | /** |
@@ -376,8 +375,7 @@ discard block |
||
| 376 | 375 | public static function iReplaceFirst($search, $replace, $subject) |
| 377 | 376 | { |
| 378 | 377 | $position = stripos($subject, $search); |
| 379 | - return $position === false ? $subject : |
|
| 380 | - substr_replace($subject, $replace, $position, strlen($search)); |
|
| 378 | + return $position === false ? $subject : substr_replace($subject, $replace, $position, strlen($search)); |
|
| 381 | 379 | } |
| 382 | 380 | |
| 383 | 381 | /** |
@@ -392,7 +390,7 @@ discard block |
||
| 392 | 390 | { |
| 393 | 391 | preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); |
| 394 | 392 | |
| 395 | - if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 393 | + if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 396 | 394 | return $value; |
| 397 | 395 | } |
| 398 | 396 | |
@@ -418,9 +416,9 @@ discard block |
||
| 418 | 416 | */ |
| 419 | 417 | public static function toBytes($string) |
| 420 | 418 | { |
| 421 | - sscanf ($string, '%u%c', $number, $suffix); |
|
| 419 | + sscanf($string, '%u%c', $number, $suffix); |
|
| 422 | 420 | if (isset ($suffix)) { |
| 423 | - $number = $number * pow (1024, strpos (' KMGTP', strtoupper($suffix))); |
|
| 421 | + $number = $number * pow(1024, strpos(' KMGTP', strtoupper($suffix))); |
|
| 424 | 422 | } |
| 425 | 423 | return $number; |
| 426 | 424 | } |
@@ -437,7 +435,7 @@ discard block |
||
| 437 | 435 | $base = log($size, 1024); |
| 438 | 436 | $suffixes = array('', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); |
| 439 | 437 | |
| 440 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
| 438 | + return round(pow(1024, $base - floor($base)), $precision).' '.$suffixes[floor($base)]; |
|
| 441 | 439 | } |
| 442 | 440 | |
| 443 | 441 | /** |
@@ -538,14 +536,14 @@ discard block |
||
| 538 | 536 | * @param array|string $allowedUnits |
| 539 | 537 | * @return bool |
| 540 | 538 | */ |
| 541 | - public static function validateNumericWithUnits($value, $allowedUnits=[]) |
|
| 539 | + public static function validateNumericWithUnits($value, $allowedUnits = []) |
|
| 542 | 540 | { |
| 543 | 541 | if (!$allowedUnits) return is_numeric($value); |
| 544 | - if (is_string($allowedUnits)) $allowedUnits=[$allowedUnits]; |
|
| 542 | + if (is_string($allowedUnits)) $allowedUnits = [$allowedUnits]; |
|
| 545 | 543 | foreach ($allowedUnits as $unit) { |
| 546 | - $checkNumber = substr($value,0, -strlen($unit)); |
|
| 544 | + $checkNumber = substr($value, 0, -strlen($unit)); |
|
| 547 | 545 | $checkUnit = substr($value, -strlen($unit)); |
| 548 | - if ($checkUnit==$unit && is_numeric($checkNumber)) { |
|
| 546 | + if ($checkUnit == $unit && is_numeric($checkNumber)) { |
|
| 549 | 547 | return true; |
| 550 | 548 | } |
| 551 | 549 | } |
@@ -540,8 +540,12 @@ |
||
| 540 | 540 | */ |
| 541 | 541 | public static function validateNumericWithUnits($value, $allowedUnits=[]) |
| 542 | 542 | { |
| 543 | - if (!$allowedUnits) return is_numeric($value); |
|
| 544 | - if (is_string($allowedUnits)) $allowedUnits=[$allowedUnits]; |
|
| 543 | + if (!$allowedUnits) { |
|
| 544 | + return is_numeric($value); |
|
| 545 | + } |
|
| 546 | + if (is_string($allowedUnits)) { |
|
| 547 | + $allowedUnits=[$allowedUnits]; |
|
| 548 | + } |
|
| 545 | 549 | foreach ($allowedUnits as $unit) { |
| 546 | 550 | $checkNumber = substr($value,0, -strlen($unit)); |
| 547 | 551 | $checkUnit = substr($value, -strlen($unit)); |
@@ -44,12 +44,12 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public static function replaceRelativeUrls($cssContent, $publishedCssFilePath) |
| 46 | 46 | { |
| 47 | - $content = preg_replace_callback('/url\(([^)]*)\)/', function ($matches) use ($publishedCssFilePath) { |
|
| 47 | + $content = preg_replace_callback('/url\(([^)]*)\)/', function($matches) use ($publishedCssFilePath) { |
|
| 48 | 48 | $url = trim($matches[1], '\'"'); |
| 49 | 49 | // ignore non url (urls e.g. data:image url paths) and absolute urls |
| 50 | 50 | if (Url::isAbsolute($url)) |
| 51 | 51 | return $matches[0]; |
| 52 | - return 'url("' . dirname($publishedCssFilePath) . '/' . $url . '")'; |
|
| 52 | + return 'url("'.dirname($publishedCssFilePath).'/'.$url.'")'; |
|
| 53 | 53 | }, $cssContent); |
| 54 | 54 | return $content; |
| 55 | 55 | } |
@@ -47,8 +47,9 @@ |
||
| 47 | 47 | $content = preg_replace_callback('/url\(([^)]*)\)/', function ($matches) use ($publishedCssFilePath) { |
| 48 | 48 | $url = trim($matches[1], '\'"'); |
| 49 | 49 | // ignore non url (urls e.g. data:image url paths) and absolute urls |
| 50 | - if (Url::isAbsolute($url)) |
|
| 51 | - return $matches[0]; |
|
| 50 | + if (Url::isAbsolute($url)) { |
|
| 51 | + return $matches[0]; |
|
| 52 | + } |
|
| 52 | 53 | return 'url("' . dirname($publishedCssFilePath) . '/' . $url . '")'; |
| 53 | 54 | }, $cssContent); |
| 54 | 55 | return $content; |
@@ -20,18 +20,18 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class ServeController extends YiiServeController |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var int port to serve on. |
|
| 25 | - */ |
|
| 26 | - public $port = 8080; |
|
| 27 | - /** |
|
| 28 | - * @var string path or path alias to directory to serve |
|
| 29 | - */ |
|
| 30 | - public $docroot = '@root/public'; |
|
| 31 | - /** |
|
| 32 | - * @var string path to router script. |
|
| 33 | - * See https://secure.php.net/manual/en/features.commandline.webserver.php |
|
| 34 | - */ |
|
| 35 | - public $router; |
|
| 23 | + /** |
|
| 24 | + * @var int port to serve on. |
|
| 25 | + */ |
|
| 26 | + public $port = 8080; |
|
| 27 | + /** |
|
| 28 | + * @var string path or path alias to directory to serve |
|
| 29 | + */ |
|
| 30 | + public $docroot = '@root/public'; |
|
| 31 | + /** |
|
| 32 | + * @var string path to router script. |
|
| 33 | + * See https://secure.php.net/manual/en/features.commandline.webserver.php |
|
| 34 | + */ |
|
| 35 | + public $router; |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if (isset($commands['core/help'])) { |
| 35 | 35 | unset($commands['core/help']); |
| 36 | 36 | } |
| 37 | - $this->stdout("\nThis is Neon version " . \Neon::getVersion() . ".\n"); |
|
| 37 | + $this->stdout("\nThis is Neon version ".\Neon::getVersion().".\n"); |
|
| 38 | 38 | if (!empty($commands)) { |
| 39 | 39 | $this->stdout("\nThe following commands are available:\n\n", Console::BOLD); |
| 40 | 40 | $len = 0; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if (!empty($actions)) { |
| 48 | 48 | $prefix = $controller->getUniqueId(); |
| 49 | 49 | foreach ($actions as $action) { |
| 50 | - $string = $prefix . '/' . $action; |
|
| 50 | + $string = $prefix.'/'.$action; |
|
| 51 | 51 | if ($action === $controller->defaultAction) { |
| 52 | 52 | $string .= ' (default)'; |
| 53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } elseif (($l = strlen($command)) > $len) { |
| 60 | 60 | $len = $l; |
| 61 | 61 | } |
| 62 | - $this->stdout('- ' . $this->ansiFormat($command, Console::FG_YELLOW)); |
|
| 62 | + $this->stdout('- '.$this->ansiFormat($command, Console::FG_YELLOW)); |
|
| 63 | 63 | $this->stdout(str_repeat(' ', $len + 4 - strlen($command))); |
| 64 | 64 | $this->stdout(Console::wrapText($description, $len + 4 + 2), Console::BOLD); |
| 65 | 65 | $this->stdout("\n"); |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | if (!empty($actions)) { |
| 72 | 72 | $prefix = $controller->getUniqueId(); |
| 73 | 73 | foreach ($actions as $action) { |
| 74 | - $string = ' ' . $prefix . '/' . $action; |
|
| 75 | - $this->stdout(' ' . $this->ansiFormat($string, Console::FG_GREEN)); |
|
| 74 | + $string = ' '.$prefix.'/'.$action; |
|
| 75 | + $this->stdout(' '.$this->ansiFormat($string, Console::FG_GREEN)); |
|
| 76 | 76 | if ($action === $controller->defaultAction) { |
| 77 | 77 | $string .= ' (default)'; |
| 78 | 78 | $this->stdout(' (default)', Console::FG_YELLOW); |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | $scriptName = $this->getScriptName(); |
| 92 | 92 | $this->stdout("\nTo see the help of each command, enter:\n", Console::BOLD); |
| 93 | - $this->stdout("\n $scriptName " . $this->ansiFormat('help', Console::FG_YELLOW) . ' ' |
|
| 94 | - . $this->ansiFormat('<command-name>', Console::FG_CYAN) . "\n\n"); |
|
| 93 | + $this->stdout("\n $scriptName ".$this->ansiFormat('help', Console::FG_YELLOW).' ' |
|
| 94 | + . $this->ansiFormat('<command-name>', Console::FG_CYAN)."\n\n"); |
|
| 95 | 95 | } else { |
| 96 | 96 | $this->stdout("\nNo commands are found.\n\n", Console::BOLD); |
| 97 | 97 | } |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function getDefaultHelpHeader() |
| 106 | 106 | { |
| 107 | - return "\nThis is Yii version " . \Yii::getVersion() . ".\n" |
|
| 108 | - . "\nThis is Neon version " . \Neon::getVersion() . ".\n"; |
|
| 107 | + return "\nThis is Yii version ".\Yii::getVersion().".\n" |
|
| 108 | + . "\nThis is Neon version ".\Neon::getVersion().".\n"; |
|
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | protected function getModuleCommands($module) |
| 116 | 116 | { |
| 117 | - $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/'; |
|
| 117 | + $prefix = $module instanceof Application ? '' : $module->getUniqueId().'/'; |
|
| 118 | 118 | |
| 119 | 119 | $commands = []; |
| 120 | 120 | |
| 121 | 121 | if ($module->id != 'core') { |
| 122 | 122 | foreach (array_keys($module->controllerMap) as $id) { |
| 123 | - $commands[] = $prefix . $id; |
|
| 123 | + $commands[] = $prefix.$id; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | $files = scandir($controllerPath); |
| 131 | 131 | foreach ($files as $file) { |
| 132 | 132 | if (!empty($file) && substr_compare($file, 'Controller.php', -14, 14) === 0) { |
| 133 | - $controllerClass = $module->controllerNamespace . '\\' . substr(basename($file), 0, -4); |
|
| 133 | + $controllerClass = $module->controllerNamespace.'\\'.substr(basename($file), 0, -4); |
|
| 134 | 134 | if ($this->validateControllerClass($controllerClass)) { |
| 135 | 135 | // if ($prefix == 'core' || $prefix == 'core/') |
| 136 | 136 | // continue; |
| 137 | - $commands[] = $prefix . Inflector::camel2id(substr(basename($file), 0, -14)); |
|
| 137 | + $commands[] = $prefix.Inflector::camel2id(substr(basename($file), 0, -14)); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class MigrateController extends \yii\console\controllers\MigrateController |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @inheritdoc |
|
| 28 | - */ |
|
| 29 | - public $templateFile = '@neon/core/views/migration.php'; |
|
| 26 | + /** |
|
| 27 | + * @inheritdoc |
|
| 28 | + */ |
|
| 29 | + public $templateFile = '@neon/core/views/migration.php'; |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @var string Define the app that is responsible for this migration. |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | if ($app === null) { |
| 77 | 77 | throw new Exception('No app exists with id "'.$this->app.'"'); |
| 78 | 78 | } |
| 79 | - $this->getMigrator()->migrationPath = $app->getClassAlias() . '/migrations'; |
|
| 79 | + $this->getMigrator()->migrationPath = $app->getClassAlias().'/migrations'; |
|
| 80 | 80 | $this->migrationPath = $this->getMigrator()->migrationPath; |
| 81 | 81 | } |
| 82 | 82 | return true; |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | if (!preg_match('/^\w+$/', $name)) { |
| 121 | 121 | throw new Exception("The migration name should contain letters, digits and/or underscore characters only."); |
| 122 | 122 | } |
| 123 | - $name = 'm' . gmdate('Ymd_His') . '_' . $app . '_' . $name; |
|
| 124 | - $file = neon()->getAlias($this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php'); |
|
| 123 | + $name = 'm'.gmdate('Ymd_His').'_'.$app.'_'.$name; |
|
| 124 | + $file = neon()->getAlias($this->migrationPath.DIRECTORY_SEPARATOR.$name.'.php'); |
|
| 125 | 125 | if ($this->confirm("Create new migration '$file'?")) { |
| 126 | 126 | $content = Yii::$app->getView()->renderFile(Neon::getAlias($this->templateFile), ['className' => $name]); |
| 127 | 127 | FileHelper::createDirectory(dirname($file)); |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | $success = $this->migrator->migrateUp($class); |
| 152 | 152 | $time = microtime(true) - $start; |
| 153 | 153 | if ($success) { |
| 154 | - $this->stdout("*** applied $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); |
|
| 154 | + $this->stdout("*** applied $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_GREEN); |
|
| 155 | 155 | return true; |
| 156 | 156 | } else { |
| 157 | - $this->stdout("*** failed to apply $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); |
|
| 157 | + $this->stdout("*** failed to apply $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_RED); |
|
| 158 | 158 | return false; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | $success = $this->migrator->migrateDown($class); |
| 172 | 172 | if ($success) { |
| 173 | 173 | $time = microtime(true) - $start; |
| 174 | - $this->stdout("*** reverted $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_GREEN); |
|
| 174 | + $this->stdout("*** reverted $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_GREEN); |
|
| 175 | 175 | return true; |
| 176 | 176 | } else { |
| 177 | 177 | $time = microtime(true) - $start; |
| 178 | - $this->stdout("*** failed to revert $class (time: " . sprintf("%.3f", $time) . "s)\n\n", Console::FG_RED); |
|
| 178 | + $this->stdout("*** failed to revert $class (time: ".sprintf("%.3f", $time)."s)\n\n", Console::FG_RED); |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -54,8 +54,9 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function getMigrator() |
| 56 | 56 | { |
| 57 | - if ($this->_migrator === null) |
|
| 58 | - $this->_migrator = new Migrator; |
|
| 57 | + if ($this->_migrator === null) { |
|
| 58 | + $this->_migrator = new Migrator; |
|
| 59 | + } |
|
| 59 | 60 | return $this->_migrator; |
| 60 | 61 | } |
| 61 | 62 | |