public function __construct(ActiveTable $activeTable, $container) { $this->id = $activeTable->getId(); // Get table type photo $helper = $container->get('vich_uploader.templating.helper.uploader_helper'); $originTableTypePicture = $container->getParameter('site_host') . $container->getParameter('base_folder_url') . $helper->asset($activeTable->getTableType(), 'table_type'); $bigTableTypePicture = str_replace($activeTable->getTableType()->getFileName(), $activeTable->getTableType()->getBigFileName(), $originTableTypePicture); if (@file_exists($bigTableTypePicture)) { $this->tableTypePicture = $bigTableTypePicture; } else { $this->tableTypePicture = $bigTableTypePicture; //Temporary solution } $this->tableNumber = $activeTable->getTableNumber(); $this->topPosition = $activeTable->getTopPosition(); $this->leftPosition = $activeTable->getLeftPosition(); $this->angle = $activeTable->getAngle(); }
/** * Add Active Table */ public function addActiveTableAction() { // get Current user $user = $this->container->get('security.context')->getToken()->getUser(); // Check if user auth in app if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException("Access denied"); } // collect data $tableNumber = $this->getRequest()->request->get('tableNumber'); $tableTop = $this->getRequest()->request->get('tableTop'); $tableLeft = $this->getRequest()->request->get('tableLeft'); $mapId = $this->getRequest()->request->get('mapId'); $tableTypeId = $this->getRequest()->request->get('tableType'); // create new Active Table $tableMap = $this->getTableMapManager()->findOneById($mapId); $tableType = $this->getTableTypeManager()->findOneById($tableTypeId); $activeTable = new ActiveTable(); $activeTable->setLeftPosition($tableLeft); $activeTable->setTableMap($tableMap); $activeTable->setTableNumber($tableNumber); $activeTable->setTableType($tableType); $activeTable->setTopPosition($tableTop); $em = $this->getDoctrine()->getManager(); $em->persist($activeTable); $em->flush(); return $this->redirect($this->generateUrl("table_viewCreateMap", array("restaurantId" => $tableMap->getRestaurant()->getId())) . "?mapId={$mapId}"); }