ソースを参照

Case conversion updates

Vijayakrishnan Krishnan 5 年 前
コミット
5fdfbdc482
1 ファイル変更7 行追加2 行削除
  1. 7 2
      app/Console/Commands/GenerateTreeCommand.php

+ 7 - 2
app/Console/Commands/GenerateTreeCommand.php

@@ -319,7 +319,8 @@ class GenController {
                 $subLinks[] = "<a " .
                     "href='/{$controller->parentControllerName}/view/<?= \$record->uid ?>/{$meth->name}' " .
                     "class='d-block p-3 py-2 border-bottom " .
-                    "{{ request()->route()->getActionMethod() === '{$meth->name}' ? 'bg-secondary text-white' : '' }}"
+                    "{{ request()->route()->getActionMethod() === '{$meth->name}' ? 'bg-secondary text-white' : '' }}" .
+                    ($meth->name === 'SUB_dashboard' ? "{{ strpos(request()->route()->getActionMethod(), 'ACTION_') === 0 ? 'bg-secondary text-white' : '' }}" : "")
                     . "'>$display</a>";
             }
             file_put_contents($subLinksView, implode("\n", $subLinks));
@@ -355,6 +356,8 @@ class GenController {
         }
         else {
             $text = str_replace("_SUB_VIEW_",
+                "<h4 class='py-3 border-bottom'>" .
+                $this->camelToTitleCase($this->snakeToTitleCase($method->name)) . "</h4>" .
                 "Controller: <b>{$controller->name}</b><br>" .
                 "Action: <b>{$method->name}()</b><br>" .
                 "View: <b>{$controller->root}/{$controller->name}/{$method->name}.blade.php</b><br>",
@@ -399,10 +402,12 @@ class GenController {
         echo "$line\n";
     }
     public function snakeToTitleCase($text) {
+        $text = preg_replace("/^(SUB|ACTION)_/", "", $text);
         return ucwords(str_replace("_", " ", $text));
     }
     public function camelToTitleCase($text) {
-        $text = preg_replace("/([A-Z])/", " $1", $text);
+        $text = preg_replace("/^(SUB|ACTION)_/", "", $text);
+        $text = preg_replace("/([a-z])([A-Z])/", "$1 $2", $text);
         return ucwords($text);
     }
     private function file_force_contents($dir, $contents){