public function reverseTransform($layoutCustomer) { if (!$layoutCustomer) { return $layoutCustomer; } $customerRepo = $this->om->getRepository('CanalTPNmmPortalBundle:Customer'); $customer = $customerRepo->find($this->customerId); $this->deleteAllLayoutsCustomer(); foreach ($layoutCustomer->getLayoutsAssigned() as $layoutSelected) { $currentLayout = new LayoutCustomer(); $currentLayout->setCustomer($customer); $currentLayout->setLayout($layoutSelected); $this->om->persist($currentLayout); } $this->om->flush(); return $layoutCustomer; }
private function assignLayoutToCustomer(ObjectManager $om, $customer) { $layout = $om->getRepository('CanalTPMttBundle:Layout')->find(1); $layoutCustomer = new LayoutCustomer(); $layoutCustomer->setCustomer($customer); $layoutCustomer->setLayout($layout); $om->persist($layoutCustomer); }