Browse Source

index template

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
bcb7545f7c
2 changed files with 38 additions and 44 deletions
  1. 18
    34
      src/Doc/Business/LuDocBusiness.php
  2. 20
    10
      src/Doc/Templates/index.html.twig

+ 18
- 34
src/Doc/Business/LuDocBusiness.php View File

@@ -26,7 +26,6 @@ class LuDocBusiness
26 26
 
27 27
         $route = LuRoute::getInstance();
28 28
         $route->get("$prefix/doc", "${ns}LuDocBusiness", "index");
29
-        $route->get("$prefix/doc/{businessHyphen}", "${ns}LuDocBusiness", "business");
30 29
         $route->get("$prefix/doc/{businessHyphen}/{method}", "${ns}LuDocBusiness", "method");
31 30
     }
32 31
 
@@ -82,47 +81,32 @@ class LuDocBusiness
82 81
         /**
83 82
          * @var $businesses LuRouteDbo[]
84 83
          */
85
-
86
-        $loader = new Twig_Loader_Filesystem(__DIR__ . "/../Templates");
87
-        $twig = new Twig_Environment($loader, array());
88
-        $template = $twig->loadTemplate("index.html.twig");
89
-        $content = $template->render(array());
90
-        echo $content;
91
-
92
-        /*foreach ($businesses_ as $businesses) {
84
+        $businesses_tiwg = [];
85
+        foreach ($businesses_ as $businesses) {
93 86
             $businessHyphen = self::getBusinessHyphen($businesses[0]->getBusinessClass());
94 87
             $businessName = self::getBusinessName($businesses[0]->getBusinessClass());
95
-            echo '<a href="doc/' . $businessHyphen . '"><h1>' . $businessName . "</h1></a>";
88
+            $business_tiwg = [];
89
+            $business_tiwg["name"] = $businessName;
90
+            $business_tiwg["name_hyphen"] = $businessHyphen;
91
+            $business_tiwg["routes"] = [];
96 92
 
97 93
             foreach ($businesses as $business) {
98
-                echo '<a href="doc/' . $businessHyphen . '/' . $business->getBusinessMethod()
99
-                    . '">' . $business->getMethod() . " " . $business->getUrl() . "</a><br />";
94
+                $business_tiwg["routes"][] = [
95
+                    "method" => $business->getMethod(),
96
+                    "url" => $business->getUrl(),
97
+                    "businessMethod" => $business->getBusinessMethod()
98
+                ];
100 99
             }
101
-        }*/
102
-        exit;
103
-    }
100
+            $businesses_tiwg[] = $business_tiwg;
101
+        }
104 102
 
103
+        $loader = new Twig_Loader_Filesystem(__DIR__ . "/../Templates");
104
+        $twig = new Twig_Environment($loader, array());
105
+        $template = $twig->loadTemplate("index.html.twig");
106
+        $content = $template->render(array("businesses" => $businesses_tiwg));
107
+        echo $content;
105 108
 
106
-    /**
107
-     * Print the help page for the selected business.
108
-     * The business must have the full namespace, hyphen separated
109
-     * eg: App-Http-Business-MyBusinessClass
110
-     * @param $businessHyphen string The business to print help
111
-     */
112
-    public static function business($businessHyphen)
113
-    {
114
-        $businesses_ = self::getBusinesses();
115
-        /**
116
-         * @var $businesses LuRouteDbo[]
117
-         */
118
-        $businesses = $businesses_[self::getBusinessFromHyphen($businessHyphen)];
119
-        $businessName = self::getBusinessName($businesses[0]->getBusinessClass());
120
-        echo '<a href="' . $businessHyphen . '"><h1>' . $businessName . "</h1></a>";
121 109
 
122
-        foreach ($businesses as $business) {
123
-            echo '<a href="' . $businessHyphen . '/' . $business->getBusinessMethod()
124
-                . '">' . $business->getMethod() . " " . $business->getUrl() . "</a><br />";
125
-        }
126 110
         exit;
127 111
     }
128 112
 

+ 20
- 10
src/Doc/Templates/index.html.twig View File

@@ -152,17 +152,27 @@
152 152
     </div>
153 153
 </header>
154 154
 <div id="body" class="help-page">
155
-    <section class="featured">
156
-        <div class="content-wrapper">
157
-            <h2>Introduction</h2>
158
-            <p>
159
-                This is the official Chronos API documentation.
160
-            </p>
161
-        </div>
162
-    </section>
163 155
     <section class="content-wrapper main-content clear-fix">
156
+        {% for business in businesses %}
157
+        <h2>{{ business.name }}</h2>
158
+        <table class="help-page-table">
159
+            <thead>
160
+            <tr><th>API</th><th>Description</th></tr>
161
+            </thead>
162
+            <tbody>
163
+            {% for route in business.routes %}
164
+            <tr>
165
+                <td class="api-name"><a href="{{ business.name_hyphen }}/{{ route.businessMethod }}">{{ route.method }} {{ route.url }}</a></td>
166
+                <td class="api-documentation">
167
+                    <p>...</p>
168
+                </td>
169
+            </tr>
170
+            {% endfor %}
171
+            </tbody>
172
+        </table>
173
+        {% endfor %}
164 174
 
165
-</section>
166
-    </div>
175
+    </section>
176
+</div>
167 177
 </body>
168 178
 </html>

Loading…
Cancel
Save