2012-06-21 60 views
1

我剛安裝FOSRestBundle I'm當我運行緩存收到此錯誤:明確無法導入資源錯誤

[Symfony\Component\Config\Exception\FileLoaderLoadException] 

    Cannot import resource "/Users/gitek/www/hotel/src/Gitek/RegistroBundle/Resources/config/routing_incidencia.yml" from "/Users/gitek/www/hotel/app/config/routing.yml". 


    [RuntimeException]                                                                       

    The autoloader expected class "Gitek\RegistroBundle\Controller\IncidenciaController" to be defined in file "/Users/gitek/www/hotel/app/../src/Gitek/RegistroBundle/Controller/IncidenciaController.php". The file was found but the class was not in it, the class name or namespace probably has a typo. 

這是我的控制器:

<?php 

namespace Gitek\RegistroBundle\Controller; 

use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use FOS\RestBundle\View\View; 
use Gitek\RegistroBundle\Entity\Registro; 
use Gitek\HotelBundle\Entity\Incidencia; 

class UsuarioController extends Controller 
{ 

    public function putIncidenciaAction($registro_id, $incidencia_id) 
    { 
     $em   = $this->get('doctrine')->getEntityManager(); 
     $registro = $em->getRepository('RegistroBundle:Registro')->find($registro_id); 
     $incidencia = $em->getRepository('HotelBundle:Incidencia')->find($incidencia_id); 

     $request = $this->getRequest(); 

     $registro->setIncidencia($incidencia); 
     $em->persist($registro); 
     $em->flush(); 

     $view = View::create(); 
     $view->setData($registro); 

     return $view; 
    } // "put_incidencia"  [PUT] /incidencia/{registro_id, incidencia_id} 

} 

這是我的#應用程序/配置/使用routing.yml

incidencias: 
    resource: "@RegistroBundle/Resources/config/routing_incidencia.yml" 
    prefix: /
    type: rest 

這是我的#SRC/Gitek/RegistroBundle /資源/配置/ routing_incidencia.yml

incidencia: 
    type:  rest 
    resource: Gitek\RegistroBundle\Controller\IncidenciaController 
    name_prefix: api_ 

最後,這是我的配置爲fos_rest上#應用程序/ config.yml:

fos_rest: 
    routing_loader: 
     default_format: null 
    view: 
     default_engine: twig 
     force_redirects: 
      html: true 
     formats: 
      json: true 
      xml: true 
     templating_formats: 
      html: true 
     view_response_listener: 'force' 
     failed_validation: HTTP_BAD_REQUEST 
    exception: 
     codes: ~ 
     messages: ~ 
    body_listener: 
     decoders: 
      json: fos_rest.decoder.json 
      xml: fos_rest.decoder.xml 
    format_listener: 
     default_priorities: [json, html, '*/*'] 
     fallback_format: html 
     prefer_extension: true 
    service: 
     router: router 
     templating: templating 
     serializer: serializer 
     view_handler: fos_rest.view_handler.default 

任何幫助或線索?

回答

2

控制器類應該被命名爲IncidenciaController代替UsuarioController

+0

朱爾!謝謝!!!我瘋了!你知道..複製和粘貼...太多了! – ikerib