0

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 "Use ....\Entity\Engineering_Detail" it throws that error on the line i'm doing $detail = new Engineering_Detail();

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

The line 403 is $detail = new Engineering_Detail();

Here's the important controller bits:

<?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->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()
             );
    }

I already checked this and verified but everything seems okay. That entity was generated using the tools inside the SF2 console. What am I doing wrong?

Note: I have already deleted cache

EDIT:

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 _ in their name.

4
  • are you sure that the namespace is correctly defined in the Engineering_Detail class? Also, is your php file name the same as the Class name? (ex. Engineering_Detail.php) Commented Nov 29, 2013 at 21:19
  • It is the same name, and the namespace for Engineering_Detail class is namespace Mine\Bundle\EngMgmtBundle\Entity; Commented Nov 29, 2013 at 21:27
  • 1
    does your constructor for the Engineering_Detail class expect a parameter that may be missing? If it's the _ that may be causing the problem, can you try the same class without the _? Commented Nov 29, 2013 at 21:48
  • I haven't declared any constructor, I'm using the same entity generated with the SF console. Same as the others I tested, it should work same as it does with the others. Commented Nov 29, 2013 at 21:50

2 Answers 2

4

you are mixing PSR namespacing and class naming. The reason why it cannot be found is because your Entity should be called EngineeringDetail to be properly found by the autoloader.

Sign up to request clarification or add additional context in comments.

2 Comments

I should give you the points, but I though you were really rude on the Issue list on github. You could've said it in a better way. Because how the hell would I know it's a bad practice?
sorry it came up wrong, did not mean to, you could have use the mailing list, that is all.
0

Fixed by deleting the _ in the entity name and changing all of its occurrences

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.