Browse files

supplements - code enlightenment

  • Loading branch information...
1 parent 7a86f9f commit 853d7426ce193a7fa8bfbb19c26b946bef361ff7 @peponi committed Mar 26, 2013
Showing with 122 additions and 131 deletions.
  1. +122 −131 index_de_2.html
View
253 index_de_2.html
@@ -121,15 +121,15 @@
<p>Damit in der View etwas angezeigt werden kann, müssen wir im Controller Sachen aus der Datenbank holen und zur View senden, da wir aber noch nichts in der Datenbank haben, ist es sinnvoll erstmal ein Formular für eine der beiden Tabellen zu bauen, um diese zu bef&uuml;llen.</p>
<p>&Ouml;ffnen wir also mal den <b>DefaultController.php</b> und schauen uns an, was bisher drin steht.</b>
<pre class="highlight">
-class DefaultController extends Controller
+<span class="k">class</span> DefaultController <span class="k">extends</span> Controller
{
- /**
+ <span class="sd">/**
* @Route("/demo"/{name})
* @Template()
- */
- public function indexAction($name)
+ */</span>
+ <span class="k">public function</span> indexAction($name)
{
- return array("name" => $name);
+ <span class="k">return</span> <span class="k">array</span>(<span class="s1">"name"</span> => $name);
}
}
</pre>
@@ -146,17 +146,17 @@
<br>
<p id="routealias">Da wir zuerst ein Formular erstellen wollen um die Datenbank zu bef&uuml;llen, erstellen wir im DefaultController eine neue Action und eine neue Route die auf diese Action verweist.</p>
<pre class="highlight">
-class DefaultController extends Controller
+<span class="k">class</span> DefaultController <span class="k">extends</span> Controller
{
...
- /**
+ <span class="sd">/**
* @Route("/insert/restaurant", name="insertrestaurant")
* @Template()
- */
- public function insertrestaurantAction()
+ */</span>
+ <span class="k">public function</span> insertrestaurantAction()
{
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig');
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>);
}
}
</pre>
@@ -176,24 +176,24 @@
<h2>Ein Formular generieren</h2>
<p>Ein Formular m&uuml;ssen wir nicht von Hand ins HTML hacken, das kann ein Formulargenerator von Symfony f&uuml;r uns &uuml;bernehmen.</p>
<pre class="highlight " id="createview">
-use YourCompany\RestaurantBundle\Entity\Restaurant;
+<span class="k">use</span> YourCompany\RestaurantBundle\Entity\Restaurant;
-class DefaultController extends Controller
+<span class="k">class</span> DefaultController <span class="k">extends</span> Controller
{
...
- public function insertrestaurantAction()
+ <span class="k">public function</span> insertrestaurantAction()
{
- $form = $this->createFormBuilder(new Restaurant)
- ->add('name', 'text',array("label" => "Name"))
- ->add('startuptime', 'datetime',array("label" => "Öffnungszeit"))
- ->add('location', 'text',array("label" => "Ort"))
- ->add('description', 'text',array("label" => "Beschreibung"))
- ->getForm();
-
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'form' => $form->createView()
+ $form = $this<span class="k">-></span>createFormBuilder(<span class="k">new</span> Restaurant)
+ <span class="k">-></span>add(<span class="s1">'name'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Name"</span>))
+ <span class="k">-></span>add(<span class="s1">'startuptime'</span>, <span class="s1">'datetime'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Öffnungszeit"</span>))
+ <span class="k">-></span>add(<span class="s1">'location'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Ort"</span>))
+ <span class="k">-></span>add(<span class="s1">'description'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Beschreibung"</span>))
+ <span class="k">-></span>getForm();
+
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="s1">'form'</span> => $form<span class="k">-></span>createView()
));
}
}
@@ -208,11 +208,11 @@
<<span class="c1">div</span> class=<span class="s1">"row-fluid"</span>>
<<span class="c1">div</span> class=<span class="s1">"span3"</span>><span class="g"> hier kommen die Links rein < /</span><span class="c1">div</span>>
<<span class="c1">div</span> class=<span class="s1">"span9"</span>><span class="g">
- <<span class="c1">form</span> action="" method="post">
+ <<span class="c1">form</span> action=<span class="s1">""</span> method=<span class="s1">"post"</span>>
hier sollen jetzt die Elemente des Formobjektes rein
- <<span class="c1">input</span> type="submit" class="btn btn-info" />
+ <<span class="c1">input</span> type=<span class="s1">"submit"</span> class=<span class="s1">"btn btn-info"</span> />
<span class="g">< /</span><span class="c1">form</span>>
< /</span><span class="c1">div</span>>
<span class="g">< /</span><span class="c1">div</span>>
@@ -224,11 +224,11 @@
<pre class="highlight">
..
<<span class="c1">div</span> class=<span class="s1">"span9"</span>><span class="g">
- <<span class="c1">form</span> action="" method="post">
+ <<span class="c1">form</span> action=<span class="s1">""</span> method=<span class="s1">"post"</span>>
- {{ form_widget(form) }}
+ {{ <span class="k">form_widget</span></7span>(form) }}
- <<span class="c1">input</span> type="submit" class="btn btn-info" />
+ <<span class="c1">input</span> type=<span class="s1">"submit"</span> class=<span class="s1">"btn btn-info"</span> />
<span class="g">< /</span><span class="c1">form</span>>
< /</span><span class="c1">div</span>>
..
@@ -238,14 +238,14 @@
<pre class="highlight">
..
<<span class="c1">div</span> class=<span class="s1">"span9"</span>><span class="g">
- <<span class="c1">form</span> action="{{ path( insertrestaurant ) }}" method="post" {{ form_enctype(form) }}>
+ <<span class="c1">form</span> action=<span class="s1">"</span>{{ <span class="k">path</span>( insertrestaurant ) }}<span class="s1">"</span> method=<span class="s1">"post"</span> {{ <span class="k">form_enctype</span>(form) }}>
- {{ form_row(form.name) }}
- {{ form_row(form.startuptime) }}
- {{ form_row(form.location) }}
- {{ form_row(form.description) }}
+ {{ <span class="k">form_row</span>(form.name) }}
+ {{ <span class="k">form_row</span>(form.startuptime) }}
+ {{ <span class="k">form_row</span>(form.location) }}
+ {{ <span class="k">form_row</span>(form.description) }}
- <<span class="c1">input</span> type="submit" class="btn btn-info" />
+ <<span class="c1">input</span> type=<span class="s1">"submit"</span> class=<span class="s1">"btn btn-info"</span> />
<span class="g">< /</span><span class="c1">form</span>>
< /</span><span class="c1">div</span>>
..
@@ -260,9 +260,9 @@
</dt>
<dd class="marginleft20px info3">
<p>Twig ist eine Auszeichnungsprache mit deren Hilfe ich die Parameter-Objeket im HTML anzeigen oder ausf&uuml;hren kann.</p>
- <code>{{ form_row(form.name) }}</code>
+ <code>{{ <span class="k">form_row</span>(form.name) }}</code>
<p>Ist genau dasselbe wie, wenn ich Folgendes schreiben würde</p>
- <code><span class="g">< ?</span><span class="sd">php</span> echo $view['form']->row($form['name']) ?></code>
+ <code><span class="g">< ?</span><span class="sd">php</span> echo $view['form']<span class="k">-></span>row($form['name']) ?></code>
<p>Aber ist doch viel sch&ouml;ner und handlicher oder?</p>
</dd>
</dl>
@@ -278,27 +278,27 @@
<pre class="highlight">
..
-public function insertrestaurantAction()
+<span class="k">public function</span> insertrestaurantAction()
{
- $form = $this->createFormBuilder(new Restaurant)
- ->add('name', 'text',array("label" => "Name"))
- ->add('startuptime', 'datetime',array("label" => "Öffnungszeit"))
- ->add('location', 'text',array("label" => "Ort"))
- ->add('description', 'text',array("label" => "Beschreibung"))
- ->getForm();
-
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'form' => $form->createView()
+ $form = $this<span class="k">-></span>createFormBuilder(<span class="k">new</span> Restaurant)
+ <span class="k">-></span>add(<span class="s1">'name'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Name"</span>))
+ <span class="k">-></span>add(<span class="s1">'startuptime'</span>, <span class="s1">'datetime'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Öffnungszeit"</span>))
+ <span class="k">-></span>add(<span class="s1">'location'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Ort"</span>))
+ <span class="k">-></span>add(<span class="s1">'description'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Beschreibung"</span>))
+ <span class="k">-></span>getForm();
+
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="s1">'form'</span> => $form<span class="k">-></span>createView()
));
}
</pre>
<p>Ein Parameter in dem die Formulardaten stecken wird hier gar nicht erwartet.</p>
<p>Das &auml;ndern wir schnell, in dem wir ein leers Objekt vom Typ Request als Parameter definieren, auf das die Formulardaten, die hier ankommen, gemappt werden können.</p>
<pre class="highlight">
-use Symfony\Component\HttpFoundation\Request;
+<span class="k">use</span> Symfony\Component\HttpFoundation\Request;
..
-public function insertrestaurantAction(Request $request)
+<span class="k">public function</span> insertrestaurantAction(Request $request)
{
..
</pre>
@@ -307,45 +307,45 @@
<pre class="highlight">
..
-public function insertrestaurantAction(Request $request)
+<span class="k">public function</span> insertrestaurantAction(Request $request)
{
- $form = $this->createFormBuilder(new Restaurant)
- ->add('name', 'text',array("label" => "Name"))
- ->add('startuptime', 'datetime',array("label" => "Öffnungszeit"))
- ->add('location', 'text',array("label" => "Ort"))
- ->add('description', 'text',array("label" => "Beschreibung"))
- ->getForm();
-
- if( $request->get("restaurant") == NULL )
+ $form = $this<span class="k">-></span>createFormBuilder(<span class="k">new</span> Restaurant)
+ <span class="k">-></span>add(<span class="s1">'name'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Name"</span>))
+ <span class="k">-></span>add(<span class="s1">'startuptime'</span>, <span class="s1">'datetime'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Öffnungszeit"</span>))
+ <span class="k">-></span>add(<span class="s1">'location'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Ort"</span>))
+ <span class="k">-></span>add(<span class="s1">'description'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Beschreibung"</span>))
+ <span class="k">-></span>getForm();
+
+ <span class="k">if</span>( $request<span class="k">-></span>get(<span class="k">"restaurant"</span>) == <span class="k">NULL</span> )
{
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'form' => $form->createView()
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="k">'form'</span> => $form<span class="k">-></span>createView()
));
}
- else
+ <span class="k">else</span>
{
- if ( $request->getMethod() == 'POST' )
+ <span class="k">if</span> ( $request<span class="k">-></span>getMethod() == <span class="s1">'POST'</span> )
{
- $form->bind($request->get("restaurant"));
+ $form<span class="k">-></span>bind($request<span class="k">-></span>get(<span class="s1">"restaurant"</span>));
- $em = $this->getDoctrine()->getEntityManager();
- $em->persist($form->getData());
- $em->flush();
+ $em = $this<span class="k">-></span>getDoctrine()<span class="k">-></span>getEntityManager();
+ $em<span class="k">-></span>persist($form<span class="k">-></span>getData());
+ $em<span class="k">-></span>flush();
- return new Response('Restaurant daten wurden in die DB geschrieben');
+ <span class="k">return</span> new Response(<span class="s1">'Restaurant daten wurden in die DB geschrieben'</span>);
}
}
}
</pre>
<p>Was wir hier tun, ist es den $request zu durchsuchen ob ein Restaurant Objekt enthalten ist, wenn nicht, dann rendern wir das index.html.twig und senden die Restaurant-Formularfelder zu dieser Datei. Wenn ein Restaurant Objekt im <b>$request</b> ist, schauen wir schnell noch ob die <a href="http://de.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTP_GET">HTTP GET Methode</a> auch POST ist und fahren fort. Die Zeile</p>
- <code>$form->bind($request->get("restaurant"));</code>
+ <code>$form<span class="k">-></span>bind($request<span class="k">-></span>get("restaurant"));</code>
<p>macht folgendes:</p>
<p>Wir rufen die <b>bind()</b> Funktion des leeren Formular-Objektes, das wir oben in der 5. Zeile generiert haben auf und &uuml;bergben ihr das Restaurant Objekt aus dem <b>$request</b> Parameter. Die <b>bind()</b> Funktion saugt jetzt alle Werte, die wir im HTML Formular eingetragen haben, aus dem <b>$request</b> Objekt raus und packt sie in das Formular-Objekt <b>$form</b>.</p>
<p>Danach erzeugen wir einen Doctrine Entity Manager der sich um unser Restaurant k&uuml;mmern soll.</p>
- <code>$em = $this->getDoctrine()->getEntityManager();</code>
+ <code>$em = $this<span class="k">-></span>getDoctrine()<span class="k">-></span>getEntityManager();</code>
<p>Diesem Entity Manager sagen wir das er Daten persistieren soll und zwar die Daten unseres $form Objektes, aus dem wir mit getData() alle wichtigen Daten raussaugen.</p>
- <code>$em->persist($form->getData());</code>
+ <code>$em<span class="k">-></span>persist($form<span class="k">-></span>getData());</code>
<p>Dann sp&uuml;len wir alles herunter mit <b>flush()</b> und <b>speichern eine neue Zeile in der Restaurant Tabelle</b>.</p>
<p>Als letztes erzeugen wir noch ein Response Objekt, da <b>jede Symfony-Controller-Funktion als Rückgabewert ein Repsonse Objekt haben muss</b>.</p>
<p>Jetzt k&ouml;nnen wir uns davon &Uuml;berzeugen das die Formulardaten in die MySQL Datenbank geschrieben wurden</p>
@@ -361,32 +361,32 @@
<p>Um die Daten, die jetzt in der Restaurant Tabelle stecken, in einer HTML Datei anzuzeigen, erzeugen wir erst mal eine neue Controllerfunktion und eine Route, die darauf verweist.</p>
<pre class="highlight">
..
-/**
+<span class="sd">/**
* @Route("/show/restaurant", name="showrestaurant")
* @Template()
- */
-public function showrestaurantAction()
+ */</span>
+<span class="k">public function</span> showrestaurantAction()
{
- $restaurants = $this->getDoctrine()->getRepository('YourCompanyRestaurantBundle:Restraurant')->findAll();
+ $restaurants = $this<span class="k">-></span>getDoctrine()<span class="k">-></span>getRepository(<span class="s1">'YourCompanyRestaurantBundle:Restraurant'</span>)<span class="k">-></span>findAll();
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig');
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>);
}
..
</pre>
<p>Um Daten aus der Datenbank zu holen verwenden wir wieder eine Funktion von Doctrine, <b/>getRepository()</b>.</p>
<pre class="highlight">
..
-/**
+<span class="sd">/**
* @Route("/show/restaurant", name="showrestaurant")
* @Template()
- */
-public function showrestaurantAction()
+ */</span>
+<span class="k">public function</span> showrestaurantAction()
{
- $restaurants = $this->getDoctrine()->getRepository('YourCompanyRestaurantBundle:Restraurant')->findAll();
+ $restaurants = $this<span class="k">-></span>getDoctrine()<span class="k">-></span>getRepository(<span class="s1">'YourCompanyRestaurantBundle:Restraurant'</span>)<span class="k">-></span>findAll();
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'restaurants' => $restaurants
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="s1">'restaurant'</span> => $restaurants
));
}
..
@@ -417,27 +417,27 @@
<<span class="c1">/tr</span>>
<<span class="c1">/thead</span>>
<<span class="c1">tbody</span>>
- {% <span class="c1">for</span> restaurant <span class="c1">in</span> restaurants %}
- <<span class="c1">tr</span>>
- <<span class="c1">td</span>>{{ restaurant.name }}<<span class="c1">/td</span>>
- <<span class="c1">td</span>>{{ restaurant.startuptime }}<<span class="c1">/td</span>>
- <<span class="c1">td</span>>{{ restaurant.location }}<<span class="c1">/td</span>>
- <<span class="c1">td</span>>{{ restaurant.description }}<<span class="c1">/td</span>>
- <<span class="c1">/tr</span>>
- {% <span class="c1">endfor</span> %}
+ {% <span class="c1">for</span> restaurant <span class="c1">in</span> restaurants %}
+ <<span class="c1">tr</span>>
+ <<span class="c1">td</span>>{{ restaurant.name }}<<span class="c1">/td</span>>
+ <<span class="c1">td</span>>{{ restaurant.startuptime }}<<span class="c1">/td</span>>
+ <<span class="c1">td</span>>{{ restaurant.location }}<<span class="c1">/td</span>>
+ <<span class="c1">td</span>>{{ restaurant.description }}<<span class="c1">/td</span>>
+ <<span class="c1">/tr</span>>
+ {% <span class="c1">endfor</span> %}
<<span class="c1">/tbody</span>>
<<span class="c1">/table</span>>
</pre>
<p>Und diesen Teil schneiden wir aus der index.html.twig und kopieren ihn in die insertrestaurant.html.twig</p>
<pre class="highlight">
-<<span class="c1">form</span> action="{{ path( insertrestaurant ) }}" method="post" {{ form_enctype(form) }}>
+<<span class="c1">form</span> action=<span class="s1">"</span>{{ <span class="k">path</span>( insertrestaurant ) }}<span class="s1">"</span> method=<span class="s1">"post"</span> {{ <span class="k">form_enctype</span>(form) }}>
-{{ form_row(form.name) }}
-{{ form_row(form.startuptime) }}
-{{ form_row(form.location) }}
-{{ form_row(form.description) }}
+{{ <span class="k">form_row</span>(form.name) }}
+{{ <span class="k">form_row</span>(form.startuptime) }}
+{{ <span class="k">form_row</span>(form.location) }}
+{{ <span class="k">form_row</span>(form.description) }}
-<<span class="c1">input</span> type="submit" class="btn btn-info" />
+<<span class="c1">input</span> type=<span class="s1">"submit"</span> class=<span class="s1">"btn btn-info"</span> />
<span class="g">< /</span><span class="c1">form</span>>
</pre>
@@ -451,9 +451,9 @@
{% <span class="c1">if</span> pathname <span class="c1">is</span> defined %}
{% <span class="c1">if</span> pathname == <span class="s1">"showrestaurant"</span> %}
- {% include <span class="s1">'YourCompanyRestaurantBundle:Default:showrestaurant.html.twig'</span> %}
+ {% <span class="k">include</span> <span class="s1">'YourCompanyRestaurantBundle:Default:showrestaurant.html.twig'</span> %}
{% <span class="c1">elseif</span> pathname == <span class="s1">"insertrestaurant"</span> %}
- {% include <span class="s1">'YourCompanyRestaurantBundle:Default:insertrestaurant.html.twig'</span> %}
+ {% <span class="k">include</span> <span class="s1">'YourCompanyRestaurantBundle:Default:insertrestaurant.html.twig'</span> %}
{% <span class="c1">endif</span> %}
{% <span class="c1">endif</span> %}
@@ -464,18 +464,18 @@
<p>Um im <b>index.html.twig</b> zu wissen welche Twig Datei eingebunden werden soll, m&uuml;ssen wir in den Controllerfunktionen einen Wert, eine Adressierung mitgeben, z.B. den <b>pathname</b> der Route.</p>
<pre class="highlight">
..
-/**
+<span class="sd">/**
* @Route("/show/restaurant", name="showrestaurant")
* @Template()
- */
-public function showrestaurantAction()
+ */</span>
+<span class="k">public function</span> showrestaurantAction()
{
- $restaurants = $this->getDoctrine()->getRepository('YourCompanyRestaurantBundle:Restraurant')->findAll();
+ $restaurants = $this<span class="k">-></span>getDoctrine()<span class="k">-></span>getRepository(<span class="s1">'YourCompanyRestaurantBundle:Restraurant'</span>)<span class="k">-></span>findAll();
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'restaurants' => $restaurants,
- <b>'pathname' => 'showrestaurant'</b>
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="s1">'restaurant'</span> => $restaurants,
+ <b><span class="s1">'pathname'</span> => <span class="s1">'showrestaurant'</span></b>
));
}
..
@@ -484,21 +484,21 @@
<pre class="highlight">
..
-public function insertrestaurantAction(Request $request)
+<span class="k">public function</span> insertrestaurantAction(Request $request)
{
- $form = $this->createFormBuilder(new Restaurant)
- ->add('name', 'text',array("label" => "Name"))
- ->add('startuptime', 'datetime',array("label"=> "Öffnungszeit"))
- ->add('location', 'text',array("label" => "Ort"))
- ->add('description', 'text',array("label" => "Beschreibung"))
- ->getForm();
-
- if( $request->get("restaurant") == NULL )
+ $form = $this<span class="k">-></span>createFormBuilder(<span class="k">new</span> Restaurant)
+ <span class="k">-></span>add(<span class="s1">'name'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Name"</span>))
+ <span class="k">-></span>add(<span class="s1">'startuptime'</span>, <span class="s1">'datetime'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Öffnungszeit"</span>))
+ <span class="k">-></span>add(<span class="s1">'location'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Ort"</span>))
+ <span class="k">-></span>add(<span class="s1">'description'</span>, <span class="s1">'text'</span>, <span class="k">array</span>(<span class="s1">"label"</span> => <span class="s1">"Beschreibung"</span>))
+ <span class="k">-></span>getForm();
+
+ <span class="k">if</span>( $request<span class="k">-></span>get("restaurant") == <span class="s1">NULL</span> )
{
- return $this->render('YourCompanyRestaurantBundle:Default:index.html.twig',
- array(
- 'form' => $form->createView(),
- <b>'pathname' => 'insertrestaurant'</b>
+ <span class="k">return</span> $this<span class="k">-></span>render(<span class="s1">'YourCompanyRestaurantBundle:Default:index.html.twig'</span>,
+ <span class="k">array</span>(
+ <span class="k">'form'</span> => $form<span class="k">-></span>createView(),
+ <b><span class="s1">'pathname'</span> => <span class="s1">'showrestaurant'</span></b>
));
}
...
@@ -525,9 +525,9 @@
{% <span class="c1">if</span> pathname <span class="c1">is</span> defined %}
{% <span class="c1">if</span> pathname == <span class="s1">"showrestaurant"</span> %}
- {% include <span class="s1">'YourCompanyRestaurantBundle:Default:showrestaurant.html.twig'</span> %}
+ {% <span class="k">include</span> <span class="s1">'YourCompanyRestaurantBundle:Default:showrestaurant.html.twig'</span> %}
{% <span class="c1">elseif</span> pathname == <span class="s1">"insertrestaurant"</span> %}
- {% include <span class="s1">'YourCompanyRestaurantBundle:Default:insertrestaurant.html.twig'</span> %}
+ {% <span class="k">include</span> <span class="s1">'YourCompanyRestaurantBundle:Default:insertrestaurant.html.twig'</span> %}
{% <span class="c1">endif</span> %}
{% <span class="c1">endif</span> %}
@@ -537,15 +537,6 @@
</pre>
<p>Und fertig. Jetzt k&ouml;nnen wir Restaurants eingeben und geordnet wieder ausgeben ohne den Browser zu verlassen.</p>
-
-
-
-
-
-
-
-
-
</section>
</div>
</div>

0 comments on commit 853d742

Please sign in to comment.