Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 2 Exception: Class not found in Controller
    text
    copied!<p>Okay so, I'm trying to create a new object of the class "Engineering_Detail" inside my custom action "next", the problem is, even though I'm using <code>"Use ....\Entity\Engineering_Detail"</code> it throws that error on the line i'm doing <code>$detail = new Engineering_Detail();</code></p> <blockquote> <p>FatalErrorException: Error: Class 'Mine\Bundle\EngMgmtBundle\Entity\Engineering_Detail' not found in C:\xampp\htdocs\EngMgmt\src\Mine\Bundle\EngMgmtBundle\Controller\EngineeringController.php line 403</p> </blockquote> <p>The line 403 is <code>$detail = new Engineering_Detail();</code></p> <p>Here's the important controller bits:</p> <pre><code>&lt;?php namespace Mine\Bundle\EngMgmtBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Mine\Bundle\EngMgmtBundle\Entity\Engineering; use Mine\Bundle\EngMgmtBundle\Form\EngineeringType; use Mine\Bundle\EngMgmtBundle\Entity\Engineering_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-&gt;getDoctrine()-&gt;getManager(); $entity = $em-&gt;getRepository('MineEngMgmtBundle:Engineering')-&gt;find($id); $current_form = $this-&gt;getForm($entity-&gt;getStatus()-&gt;getInternalOrder()); $current_form-&gt;handleRequest($request); $detail = new Engineering_Detail(); if ($current_form-&gt;isValid()) { $data = $current_form-&gt;getData(); switch ($entity-&gt;getStatus()-&gt;getInternalOrder()){ case 1: if (($data["sitesurvey"]) == 'n'){ $status = $em-&gt;getRepository('MineEngMgmtBundle:Status')-&gt;findBy(array('internalOrder' =&gt; 8)); $next_form = $this-&gt;getForm($entity-&gt;getStatus()-&gt;getInternalOrder()); }else{ $status = $em-&gt;getRepository('MineEngMgmtBundle:Status')-&gt;find(2); $next_form = $this-&gt;getForm($entity-&gt;getStatus()-&gt;getInternalOrder()); } break; default: $status = $em-&gt;getRepository('MineEngMgmtBundle:Status')-&gt;findBy(array('internalOrder' =&gt; $entity-&gt;getStatus()-&gt;getInternalOrder()+1)); $next_form = $this-&gt;getForm($entity-&gt;getStatus()-&gt;getInternalOrder()); break; } $detail-&gt;setEngineering($entity); $detail-&gt;setFromStatus($entity-&gt;getStatus()); $detail-&gt;setToStatus($status); $detail-&gt;setUpdatedDate(new \DateTime()); $detail-&gt;setUser($this-&gt;get('security.context')-&gt;getToken()-&gt;getUser()); $detail-&gt;setComments($data["comments"]); $entity-&gt;setStatus($status); $em-&gt;flush(); } return array( 'entity' =&gt; $entity, 'form' =&gt; $next_form-&gt;createView() ); } </code></pre> <p>I already checked <a href="https://stackoverflow.com/questions/19170948/symfony-2-class-not-found-in-controller">this</a> and verified but everything seems okay. That entity was generated using the tools inside the SF2 console. What am I doing wrong?</p> <p>Note: I have already deleted cache</p> <p><strong>EDIT:</strong></p> <p>Tried with all other entities, using the same namespace and just changing the entity's name, and declaring objects, it seems the issue it's just with the entities with the <strong>_</strong> in their name. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload