title: Call custom function of controller from ajax symfony2
body: <p>I've created the forms using Sonata Admin Bundle. Then I've created my own Controller (TestController) and override the CRUD controller,</p>
  
  <p>I've added a new function in the TestController,</p>
  
  <pre><code>namespace IFI2\MainProjectBundle\Controller;
  
  use Symfony\Component\Security\Core\SecurityContextInterface;
  use Symfony\Bridge\Monolog\Logger;
  use Sonata\AdminBundle\Controller\CRUDController as Controller;
  
  
  //use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Response;
  
  class TestController extends Controller
  {
  
      public function getProductPricesAction() {
  
           file_put_contents("/Applications/XAMPP/htdocs/IFI2 CMS/Logs.txt","HELO",FILE_APPEND);
  
            return new Response(json_encode($response)); 
  
      }
  }
  </code></pre>
  
  <p>Then I'm trying to access this function via my javascript Code,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      function test1() {
  
          $.ajax({
              type:"POST",
              //dataType: "json",
              url: '{{ path('main_project.admin.test')}}',
              success: function(successMsg) {
                  alert("successMsg");
  
              },
              error: function(errorMsg) {
                  alert("errorMsg");
  
              }
          });
       }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here's my routing.yml,</p>
  
  <pre><code>main_project.admin.test:
    pattern:  /getProductPrices/
    defaults: { _controller: IFI2MainProjectBundle:Test:getProductPrices}
  </code></pre>
  
  <p>I've already had services.yml entry for this entity,</p>
  
  <pre><code>main_project.admin.cobrand:
      class: MainProjectBundle\Admin\TestAdmin
      arguments: [~, MainProjectBundle\Entity\Test, "MainProjectBundle:Test"]
      tags:
          - {name: sonata.admin, manager_type: orm, group: admin, label: Test}
      calls:
          - [setTemplate, [edit, MainProjectBundle:Test:edit.html.twig]]
  </code></pre>
  
  <p>I'm getting the following error in my response,</p>
  
  <p>There is no <code>_sonata_admin</code> defined for the controller <code>MainProjectBundle\Controller\TestController</code> and the current route <code>main_project.admin.test</code> </p>
  
  <p>Kindly, help me how to embed it ?</p>
  
  <p>Thanks,
  Faisal Nasir</p>