public function executeSupportCreditOrder(Order $order) { $product = $order->getProduct(); $details = $product->getDetails(); $nbCredits = $details['nb_credits']; $this->creditSupportManager->addCreditsToUser($order->getChart()->getOwner(), $nbCredits); }
public function addRemoteWorkspaceExpDate(Order $order) { $sws = $order->getSharedWorkspace(); $user = $sws->getOwner(); $monthDuration = $order->getPriceSolution()->getMonthDuration(); $product = $order->getProduct(); $details = $product->getDetails(); $workspace = $this->getWorkspaceData($sws); $expDate = \DateTime::createFromFormat(\DateTime::ATOM, $workspace['endDate']); $now = new \DateTime(); if ($now->getTimeStamp() > $expDate->getTimeStamp()) { $expDate = $now; } $interval = new \DateInterval("P{$monthDuration}M"); $expDate->add($interval); $workspaceType = new WorkspaceType(); $workspaceType->enableApi(); $form = $this->formFactory->create($workspaceType); $payload = $this->apiManager->formEncode($workspace, $form, $workspaceType); $payload['workspace_form[endDate]'] = $expDate->format('d-m-Y'); $url = 'api/workspaces/' . $sws->getRemoteId() . '/users/' . $user->getUsername() . '.json'; $serverOutput = $this->apiManager->url($this->targetFriend, $url, $payload, 'PUT'); $workspace = json_decode($serverOutput, true); //add date here if ($workspace === null || isset($workspace['errors'])) { $this->handleError($sws, $serverOutput, $url); } if (array_key_exists('id', $workspace)) { $updatedDate = new \DateTime(); $updatedDate->setTimeStamp($expDate->getTimeStamp()); $sws->setExpDate($updatedDate); $this->om->persist($sws); $this->om->flush(); return $sws; } $this->handleError($sws, $serverOutput, $url); }