Symfony 2异常:在控制器中找不到类



好吧,我正试图在我的自定义操作"next"中创建一个类为"Engineering_Detail"的新对象,问题是,即使我使用"Use ....EntityEngineering_Detail",它也会在我执行$detail = new Engineering_Detail(); 的行上抛出错误

致命错误异常:错误:在C:\examplep\htdocs\EngMgmt\src\Mine\Bundle\EngMgmtBundle\Controller\EngineeringController.php行403 中找不到类"Mine\Bundle\IngMgmtBundle \Entity\Engineering_Detail"

线路403为$detail = new Engineering_Detail();

以下是重要的控制器位:

<?php
namespace MineBundleEngMgmtBundleController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyBundleFrameworkBundleControllerController;
use SensioBundleFrameworkExtraBundleConfigurationMethod;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SensioBundleFrameworkExtraBundleConfigurationTemplate;
use MineBundleEngMgmtBundleEntityEngineering;
use MineBundleEngMgmtBundleFormEngineeringType;
use MineBundleEngMgmtBundleEntityEngineering_Detail;
/**
 * Engineering controller.
 *
 * @Route("/engineering")
 */
class EngineeringController extends Controller
{
/**
     * Updates a Engineering entity.
     *
     * @Route("/{id}/next/", name="engineering_next")
     * @Method("POST")
     * @Template("MineEngMgmtBundle:Engineering:update.html.twig")
     */
   public function nextAction(Request $request, $id){
        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository('MineEngMgmtBundle:Engineering')->find($id);
        $current_form = $this->getForm($entity->getStatus()->getInternalOrder()); 
        $current_form->handleRequest($request);
        $detail = new Engineering_Detail();
        if ($current_form->isValid()) {
            $data = $current_form->getData();
            switch ($entity->getStatus()->getInternalOrder()){
                case 1:
                 if (($data["sitesurvey"]) == 'n'){
                     $status = $em->getRepository('MineEngMgmtBundle:Status')->findBy(array('internalOrder' => 8));
                     $next_form = $this->getForm($entity->getStatus()->getInternalOrder());
                }else{
                     $status = $em->getRepository('MineEngMgmtBundle:Status')->find(2);
                     $next_form = $this->getForm($entity->getStatus()->getInternalOrder());
                }    
                    break;
                default:
                     $status = $em->getRepository('MineEngMgmtBundle:Status')->findBy(array('internalOrder' => $entity->getStatus()->getInternalOrder()+1));
                     $next_form = $this->getForm($entity->getStatus()->getInternalOrder());
                    break;
            }
                     $detail->setEngineering($entity);
                     $detail->setFromStatus($entity->getStatus());
                     $detail->setToStatus($status);
                     $detail->setUpdatedDate(new DateTime());
                     $detail->setUser($this->get('security.context')->getToken()->getUser());
                     $detail->setComments($data["comments"]);
                     $entity->setStatus($status);
                     $em->flush();
        }
            return array(
                        'entity' => $entity,
                        'form'   => $next_form->createView()
             );
    }

我已经对此进行了检查和验证,但一切似乎都很好。该实体是使用SF2控制台中的工具生成的。我做错了什么?

注意:我已经删除了缓存

编辑:

尝试使用所有其他实体,使用相同的命名空间,只更改实体的名称并声明对象,问题似乎只是名称中带有_的实体。

您正在混合PSR名称空间和类命名。找不到它的原因是,您的实体应被称为EngineeringDetail,以便自动加载器正确找到。

通过删除实体名称中的_并更改其所有出现次数来修复

最新更新