I am making a application with multiply bundels and database connections.
I keep getting this error: The class 'ScheduleBundle\Entity\schedule' was not found in the chain configured namespaces StudentsBundle\Entity 500 Internal Server Error - MappingException
Here is the code from the controller
<?php
namespace ScheduleBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
//Json Response
use Symfony\Component\HttpFoundation\JsonResponse;
//Class Controller
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
//Request
use Symfony\Component\HttpFoundation\Request;
use ScheduleBundle\Entity\schedule;
class ApiController extends Controller
{
/**
* @Route("/api/{week}")
*/
public function roosterApi(Request $request, $week)
{
$rooster = array('week' => '1');
$entityManager = $this->get('doctrine')->getManager();
$roosterConnection = $this->get('doctrine')->getRepository('ScheduleBundle:schedule', 'schedule');
$dataRooster = $roosterConnection->findOneByStudentId('36838');
$dataRooster->setSchedule($rooster);
$entityManager->persist($dataRooster);
$entityManager->flush();
$out = array('1' => $week);
return new JsonResponse($out, 200, array('Content-Type' => 'application/json'));
}
}
?>
I think the problem is with my orm mapping so i include the doctrine code from config.yml
# Doctrine Configuration
doctrine:
dbal:
default_connection: StudentDB
connections:
StudentDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_students%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
TeacherDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_teachers%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
GradesDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_grades%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
ScheduleDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_schedule%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
SpecialGroupDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_specialgroup%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
ToDoListDB:
driver: '%database_driver%'
host: '%database_host%'
port: '%database_port%'
dbname: '%database_todolist%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
orm:
default_entity_manager: students
entity_managers:
students:
connection: StudentDB
mappings:
StudentsBundle: ~
teachers:
connection: TeacherDB
mappings:
TeachersBundle: ~
grades:
connection: GradesDB
mappings:
GradesBundle: ~
schedule:
connection: ScheduleDB
mappings:
ScheduleBundle: ~
specialgroup:
connection: SpecialGroupDB
mappings:
SpecialGroupBundle: ~
todolist:
connection: ToDoListDB
mappings:
ToDoListBundle: ~
I am using symfony 3.0.3 and doctrine
edit: changed use ScheduleBundle\Entity to use ScheduleBundle\Entity\schedule this did not fix the problem