public function addSharedWorkspace(Order $order) { $priceSolution = $order->getPriceSolution(); $duration = $priceSolution->getMonthDuration(); $product = $order->getProduct(); $user = $order->getChart()->getOwner(); //get the duration right $details = $product->getDetails(); $expDate = new \DateTime(); if ($order->hasDiscount()) { $duration += $this->ch->getParameter('formalibre_test_month_duration'); } $interval = new \DateInterval("P{$duration}M"); $expDate->add($interval); $sws = new SharedWorkspace(); $sws->setOwner($user); $sws->setMaxUser($details['max_users']); $sws->setMaxRes($details['max_resources']); $sws->setMaxStorage($details['max_storage']); $sws->setExpDate($expDate); $sws->setRemoteId(0); //if it wasn't created properly, 0 means somethung went wrong obv. $this->om->persist($sws); $this->om->flush(); return $sws; }