Эх сурвалжийг харах

Controlleur de tests ajax

François 6 жил өмнө
parent
commit
f111f96b96

+ 81 - 41
.idea/workspace.xml

@@ -2,6 +2,8 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="19fd33e1-3e6e-469c-a5f8-ac62ca30af41" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/src/AppBundle/Controller/AjaxController.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.settings/org.eclipse.wst.validation.prefs" beforeDir="false" />
       <change beforePath="$PROJECT_DIR$/app/Resources/views/base.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/app/Resources/views/base.html.twig" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/app/config/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/app/config/config.yml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
@@ -10,9 +12,7 @@
       <change beforePath="$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/AppBundle/Entity/Film.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Entity/Film.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/AppBundle/Repository/RealisateurRepository.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Repository/RealisateurRepository.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/liste.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/liste.html.twig" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/modifier.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/modifier.html.twig" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig" afterDir="false" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="SHOW_DIALOG" value="false" />
@@ -36,27 +36,38 @@
       <usages-collector id="statistics.file.extensions.open">
         <counts>
           <entry key="json" value="1" />
+          <entry key="php" value="1" />
           <entry key="twig" value="3" />
-          <entry key="yml" value="1" />
+          <entry key="yml" value="2" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.open">
         <counts>
           <entry key="JSON" value="1" />
+          <entry key="PHP" value="1" />
           <entry key="Twig" value="3" />
-          <entry key="YAML" value="1" />
+          <entry key="YAML" value="2" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
+          <entry key="php" value="383" />
           <entry key="twig" value="9" />
         </counts>
       </usages-collector>
       <usages-collector id="statistics.file.types.edit">
         <counts>
+          <entry key="PHP" value="383" />
           <entry key="Twig" value="9" />
         </counts>
       </usages-collector>
+      <usages-collector id="statistics.vcs.git.usages" />
+      <usages-collector id="statistics.js.language.service.starts" />
+      <usages-collector id="statistics.php.new.test" />
+      <usages-collector id="statistics.php.composer.actions" />
+      <usages-collector id="statistics.php.new.class" />
+      <usages-collector id="statistics.php.composer.command.options" />
+      <usages-collector id="statistics.php.rename.constructor" />
     </session>
   </component>
   <component name="FileEditorManager">
@@ -64,44 +75,44 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="900">
-              <caret line="93" column="45" lean-forward="true" selection-start-line="93" selection-start-column="45" selection-end-line="93" selection-end-column="45" />
+            <state relative-caret-position="90">
+              <caret line="6" column="45" selection-start-line="6" selection-start-column="45" selection-end-line="6" selection-end-column="45" />
               <folding>
+                <element signature="e#1385#1404#1#PHP" expanded="true" />
                 <element signature="e#1744#1760#1#PHP" expanded="true" />
-                <element signature="e#2666#2689#1#PHP" expanded="true" />
+                <element signature="e#2111#2130#1#PHP" expanded="true" />
               </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig">
+        <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/AjaxController.php">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="75">
-              <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
+            <state relative-caret-position="180">
+              <caret line="21" column="9" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="9" />
               <folding>
-                <element signature="e#12#26#0#Twig" expanded="true" />
+                <element signature="e#40#73#0#PHP" expanded="true" />
+                <element signature="e#911#934#1#PHP" expanded="true" />
               </folding>
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig">
+        <entry file="file://$PROJECT_DIR$/app/config/routing.yml">
           <provider selected="true" editor-type-id="text-editor">
-            <state>
-              <folding>
-                <element signature="e#12#43#0#Twig" expanded="true" />
-              </folding>
+            <state relative-caret-position="45">
+              <caret line="3" lean-forward="true" selection-start-line="3" selection-end-line="3" />
             </state>
           </provider>
         </entry>
       </file>
       <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/testajax.html.twig">
+        <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="217">
-              <caret line="66" column="33" selection-start-line="66" selection-start-column="33" selection-end-line="66" selection-end-column="33" />
+            <state relative-caret-position="105">
+              <caret line="7" lean-forward="true" selection-start-line="7" selection-end-line="7" />
               <folding>
                 <element signature="e#12#43#0#Twig" expanded="true" />
               </folding>
@@ -119,6 +130,8 @@
       <list>
         <option value="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/testajax.html.twig" />
         <option value="$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig" />
+        <option value="$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php" />
+        <option value="$PROJECT_DIR$/src/AppBundle/Controller/AjaxController.php" />
       </list>
     </option>
   </component>
@@ -128,6 +141,9 @@
     <detection-done>true</detection-done>
     <sorting>DEFINITION_ORDER</sorting>
   </component>
+  <component name="PhpServers">
+    <servers />
+  </component>
   <component name="PhpWorkspaceProjectConfiguration">
     <include_path>
       <path value="$PROJECT_DIR$/vendor/incenteev/composer-parameter-handler" />
@@ -189,6 +205,17 @@
               <item name="films" type="b2602c69:ProjectViewProjectNode" />
               <item name="films" type="462c0819:PsiDirectoryNode" />
             </path>
+            <path>
+              <item name="films" type="b2602c69:ProjectViewProjectNode" />
+              <item name="films" type="462c0819:PsiDirectoryNode" />
+              <item name="app" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="films" type="b2602c69:ProjectViewProjectNode" />
+              <item name="films" type="462c0819:PsiDirectoryNode" />
+              <item name="app" type="462c0819:PsiDirectoryNode" />
+              <item name="config" type="462c0819:PsiDirectoryNode" />
+            </path>
             <path>
               <item name="films" type="b2602c69:ProjectViewProjectNode" />
               <item name="films" type="462c0819:PsiDirectoryNode" />
@@ -266,12 +293,12 @@
       <option name="presentableId" value="Default" />
       <updated>1539955568381</updated>
       <workItem from="1539955571597" duration="339000" />
-      <workItem from="1539955933558" duration="270000" />
+      <workItem from="1539955933558" duration="1424000" />
     </task>
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="609000" />
+    <option name="totallyTimeSpent" value="1763000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="0" y="27" width="1366" height="741" extended-state="6" />
@@ -291,7 +318,7 @@
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
       <window_info anchor="bottom" id="Version Control" order="9" show_stripe_button="false" />
       <window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49924242" visible="true" weight="0.3283582" />
-      <window_info anchor="bottom" id="Event Log" order="11" sideWeight="0.5007576" side_tool="true" visible="true" weight="0.3283582" />
+      <window_info anchor="bottom" id="Event Log" order="11" sideWeight="0.5007576" side_tool="true" weight="0.3283582" />
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -318,49 +345,62 @@
     <entry file="file://$PROJECT_DIR$/package.json">
       <provider selected="true" editor-type-id="text-editor" />
     </entry>
-    <entry file="file://$PROJECT_DIR$/app/config/routing.yml">
+    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="15">
-          <caret line="1" column="4" selection-start-line="1" selection-start-column="4" selection-end-line="1" selection-end-column="4" />
+        <state relative-caret-position="75">
+          <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
+          <folding>
+            <element signature="e#12#26#0#Twig" expanded="true" />
+          </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php">
+    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/testajax.html.twig">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="900">
-          <caret line="93" column="45" lean-forward="true" selection-start-line="93" selection-start-column="45" selection-end-line="93" selection-end-column="45" />
+        <state relative-caret-position="202">
+          <caret line="71" column="9" lean-forward="true" selection-start-line="71" selection-start-column="9" selection-end-line="71" selection-end-column="9" />
           <folding>
-            <element signature="e#1744#1760#1#PHP" expanded="true" />
-            <element signature="e#2666#2689#1#PHP" expanded="true" />
+            <element signature="e#12#43#0#Twig" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/testajax.html.twig">
+    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="217">
-          <caret line="66" column="33" selection-start-line="66" selection-start-column="33" selection-end-line="66" selection-end-column="33" />
+        <state relative-caret-position="105">
+          <caret line="7" lean-forward="true" selection-start-line="7" selection-end-line="7" />
           <folding>
             <element signature="e#12#43#0#Twig" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/ajouter.html.twig">
+    <entry file="file://$PROJECT_DIR$/app/config/routing.yml">
       <provider selected="true" editor-type-id="text-editor">
-        <state>
+        <state relative-caret-position="45">
+          <caret line="3" lean-forward="true" selection-start-line="3" selection-end-line="3" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/VideothequeController.php">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="90">
+          <caret line="6" column="45" selection-start-line="6" selection-start-column="45" selection-end-line="6" selection-end-column="45" />
           <folding>
-            <element signature="e#12#43#0#Twig" expanded="true" />
+            <element signature="e#1385#1404#1#PHP" expanded="true" />
+            <element signature="e#1744#1760#1#PHP" expanded="true" />
+            <element signature="e#2111#2130#1#PHP" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/src/AppBundle/Resources/views/videotheque/base.html.twig">
+    <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/AjaxController.php">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="75">
-          <caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
+        <state relative-caret-position="180">
+          <caret line="21" column="9" selection-start-line="21" selection-start-column="9" selection-end-line="21" selection-end-column="9" />
           <folding>
-            <element signature="e#12#26#0#Twig" expanded="true" />
+            <element signature="e#40#73#0#PHP" expanded="true" />
+            <element signature="e#911#934#1#PHP" expanded="true" />
           </folding>
         </state>
       </provider>

+ 45 - 0
src/AppBundle/Controller/AjaxController.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace AppBundle\Controller;
+
+use AppBundle\Entity\Realisateur;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
+
+class AjaxController extends Controller
+{
+    /**
+     * @Route("/ajax", name="ajax_recherche")
+     */
+    public function ajaxAction (Request $request)
+    {
+        $realisateur = new Realisateur();
+        $realisateur->setNom('Drouhard');
+        $realisateur->setPrenom('François');
+
+        $realisateur = $this->get('serializer')->serialize($realisateur, 'json');
+        return new JsonResponse($realisateur);
+    }
+
+    /**
+     * @Route("/rqajax", name="ajax_requete_ajax")
+     */
+    public function requeteAjaxAction(Request $request)
+    {
+        $em = $this->getDoctrine()->getManager();
+        $repo = $em->getRepository('AppBundle:Realisateur');
+        $resultats = $repo->findByNom($request->request->get('mot_cle'));
+        if ($request->isXmlHttpRequest())
+        {
+            foreach ($resultats as $key=>$realisateur) {
+                $resultats[$key] = $this->get('serializer')->serialize($realisateur, 'json');
+            }
+            return new JsonResponse($resultats);
+        }
+        return $this->render ('@App/videotheque/testajax.html.twig', array (
+            'realisateurs' => $resultats
+        ));
+    }
+}

+ 0 - 22
src/AppBundle/Controller/VideothequeController.php

@@ -5,8 +5,6 @@ namespace AppBundle\Controller;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpFoundation\JsonResponse;
 use AppBundle\Entity\Film;
 use AppBundle\Form\FilmType;
 
@@ -100,24 +98,4 @@ class VideothequeController extends Controller
 		));
 	}
 
-    /**
-	 * @Route("/rqajax", name="videotheque_requete_ajax")
-	 */
-	public function requeteAjaxAction(Request $request)
-	{	    
-        $em = $this->getDoctrine()->getManager();
-        $repo = $em->getRepository('AppBundle:Realisateur');
-        $resultats = $repo->findByNom($request->request->get('mot_cle'));
-	    if ($request->isXmlHttpRequest())
-	    {
-	        foreach ($resultats as $key=>$realisateur) {
-    	        $resultats[$key] = $this->get('serializer')->serialize($realisateur, 'json');
-    	    }
-	        return new JsonResponse($resultats);
-    	}
-    	return $this->render ('@App/videotheque/testajax.html.twig', array (
-    	    'realisateurs' => $resultats
-	    ));
-	}	    
-
 }

+ 9 - 0
src/AppBundle/Tests/Controller/AjaxControllerTest.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace AppBundle\Tests\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+
+class AjaxControllerTest extends WebTestCase
+{
+}