MVCFramework.xml.diff

Irene Höppner, 2008-12-03 22:49

Download (4.34 KB)

View differences:

MVCFramework.xml (working copy)
136 136
      Controller/
137 137
        F3_Demo_Controller_DefaultController.php
138 138
      View/
139
        Default/
140
          F3_Demo_View_Default_DefaultView.php</literallayout>
139
        F3_Demo_View_DefaultIndex.php</literallayout>
141 140

  
142 141
      <para>The view's code is equally trivial:</para>
143 142

  
......
146 145

  
147 146
        <programlisting>namespace F3::Demo::View;
148 147

  
149
class DefaultView extends F3::FLOW3::MVC::View::AbstractView {
148
class DefaultIndex extends F3::FLOW3::MVC::View::AbstractView {
150 149
   public function render() {
151 150
      return "Hello World!";
152 151
   }
......
191 190

  
192 191
        <listitem>
193 192
          <para><emphasis>View</emphasis> classes are situated below a
194
          <filename>View</filename> directory. They are grouped by controllers
195
          and named by their actions: Directories below the
196
          <filename>View</filename> folder are named after the controller and
197
          the view's class name refers to the action.</para>
193
          <filename>View</filename> directory. The classname of the view is a
194
          combination of the name of the controller and the name of the
195
          action.</para>
198 196
        </listitem>
199 197
      </itemizedlist>
200 198

  
......
211 209
        F3_Demo_Controller_CustomerController.php
212 210
        F3_Demo_Controller_OrderController.php
213 211
      View/
214
        Default/
215
          F3_Demo_View_Default_DefaultView.php
216
        Customer/
217
          F3_Demo_View_Customer_DefaultView.php
218
          F3_Demo_View_Customer_ListView.php
219
          F3_Demo_View_Customer_DetailsView.php
220
        Order/
221
          F3_Demo_View_Order_ListView.php</literallayout>
212
        F3_Demo_View_DefaultIndex.php
213
        F3_Demo_View_CustomerIndex.php
214
        F3_Demo_View_CustomerList.php
215
        F3_Demo_View_CustomerDetails.php
216
        F3_Demo_View_OrderList.php</literallayout>
222 217
      </example>
223 218

  
224
      <para>Adhering to these conventions has the advantage that views for
225
      example are resolved automatically. However it is possible (and not
226
      really difficult) to deviate from this layout and have a completely
227
      different structure.</para>
219
      <para>Adhering to these conventions has the advantage that the classname
220
      of the view for example is resolved automatically. However it is
221
      possible (and not really difficult) to deviate from this layout and have
222
      a completely different structure.</para>
228 223
    </section>
224

  
225
    <section>
226
      <title>From the URI to the view</title>
227

  
228
      <caution>
229
        <para>For the example URIs we assume that the web root directory of
230
        your local server points to FLOW3's <filename>public/</filename>
231
        directory. If that's not the case you have to extend the URI
232
        accordingly.</para>
233
      </caution>
234

  
235
      <para>FLOW3 provides a standard way of resolving the URI to your
236
      MVC-Objects.</para>
237

  
238
      <para>Say, you want to see the list of customers (based on the
239
      file-structure-example above). The URI to get the list would be:
240
      <uri>http://localhost/demo/customer/list.html</uri> or just
241
      <uri>http://localhost/demo/customer/list</uri>.</para>
242

  
243
      <para>This URI will be resolved into the package-name
244
      (<emphasis>Demo</emphasis>), controller-name
245
      (<emphasis>Customer</emphasis>), action-name(<emphasis>list</emphasis>)
246
      and format-name (<emphasis>html</emphasis> - which is the default
247
      format).</para>
248

  
249
      <para>Depending on that, the controller
250
      <classname>F3::Demo::Controller::CustomerController</classname>
251
      (Pattern:
252
      '<code>F3::@package::Controller::@controllerController'</code>) and its
253
      method <methodname>listAction()</methodname> will be used. The
254
      corresponding view is
255
      <classname>F3::Demo::View::CustomerList</classname> (Pattern:
256
      <code>'F3::@package::View::@controller@action@format'</code>).</para>
257

  
258
      <para>If you have a look at the view pattern, you see, that you can
259
      easily add a view that creates an xml-output by creating the class
260
      <classname>F3::Demo::View::CustomerListXML</classname>. You will get the
261
      xml-output by calling the URI
262
      <uri>http://localhost/demo/customer/list.xml</uri>.</para>
263
    </section>
229 264
  </section>
230 265

  
231 266
  <section>