public function createIntegration(CreateIntegrationCommand $command) { if ($integration = $this->getIntegration($command->type)) { throw new \RuntimeException(sprintf("%s integration is already configured in your system", $integration->getName())); } $integration = new Integration($command->name, $command->type, $command->accessKey); if (!empty($integration->getAccessKey())) { $integration->enable(); } $this->saveIntegration($integration); return $integration; }
public function processAttachments($attachments, Integration $integration) { $transport = $this->transportPool->getTransport($integration->getType()); $transport->initClient(); $_em = $this->registry->getManager(); /** @var Attachment $attachment */ foreach ($attachments as $attachment) { if ($transport->fileExists($attachment->getHash())) { continue; } $transport->upload($attachment); $attachmentIntegration = new AttachmentIntegration($attachment, $integration); $_em->persist($attachmentIntegration); } $_em->flush(); }