/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $rooms = [['number' => 200, 'beacon' => 200, 'nfcTag' => null], ['number' => 400, 'beacon' => 400, 'nfcTag' => null], ['number' => 100, 'beacon' => null, 'nfcTag' => null], ['number' => 101, 'beacon' => null, 'nfcTag' => null], ['number' => 102, 'beacon' => null, 'nfcTag' => null], ['number' => 103, 'beacon' => null, 'nfcTag' => null], ['number' => 104, 'beacon' => null, 'nfcTag' => null], ['number' => 105, 'beacon' => null, 'nfcTag' => null], ['number' => 106, 'beacon' => null, 'nfcTag' => null]]; foreach ($rooms as $room) { $roomObj = new Room(); $roomObj->setBeacon($room['beacon'])->setNumber($room['number'])->setNfcTag($room['nfcTag']); $manager->persist($roomObj); $manager->flush(); $this->addReference('room-' . $roomObj->getNumber(), $roomObj); } }
/** * @param Room $room * @return User[] * @View(serializerGroups={"default", "withRoom"}) * @ApiDoc( * section="Users", * description="Returns all users in room as an array", * output={ * "class" = "AppBundle\Entity\User", * "groups" = {"default", "withRoom"} * } * ) */ public function getRoomUsersAction(Room $room) { return $room->getUsers(); }
/** * Creates a form to delete a Room entity by id. * * @param Room $room * * @return \Symfony\Component\Form\Form */ private function createDeleteForm(Room $room) { return $this->createFormBuilder()->setAction($this->generateUrl('room_delete', array('id' => $room->getId())))->setMethod('DELETE')->getForm(); }