private function createBlock(ObjectManager $em, $timetable, $typeId = BlockRepository::TEXT_TYPE) { $block = new Block(); $block->setTimetable($timetable); $block->setTypeId($typeId); $block->setDomId('timegrid_block_1'); $block->setContent('test'); $block->setTitle('title'); $em->persist($block); return $block; }
/** * find a block by Route Id And DomId * * @param string $lineId Line Id in meth db * @param string $domId Dom Id in layout * @return Block Entity or null */ public function findByTimetableAndDomId($timetableId, $domId) { $block = $this->findOneBy(array('timetable' => $timetableId, 'domId' => $domId)); // no block found so create first a non persistent block if (empty($block)) { $block = new Block(); $block->setDomId($domId); $timetable = $this->getEntityManager()->getRepository('CanalTPMttBundle:Timetable')->find($timetableId); $block->setTimetable($timetable); } return $block; }