示例#1
0
 public function load(ObjectManager $manager)
 {
     $disciplines = ['Математика', 'Физика', 'Химия', 'Геометрия', 'История', 'Русский язык', 'Литература', 'Химия', 'Физ-ра', 'Труды', 'Природоведение'];
     foreach ($disciplines as $discipline) {
         $student = new Discipline();
         $student->setTitle($discipline);
         $manager->persist($student);
     }
     $manager->flush();
 }
 /**
  * Добавляет предмет
  *
  * @Route("/")
  * @Method("POST")
  */
 public function addAction()
 {
     $request = Request::createFromGlobals();
     $data = json_decode($request->getContent());
     $d = new Discipline();
     $d->setTitle($data->title);
     $em = $this->getDoctrine()->getManager();
     $em->persist($d);
     $em->flush();
     return new JsonResponse(['success' => true, 'data' => ['id' => $d->getId(), 'title' => $d->getTitle()]]);
 }