Пример #1
0
 /**
  * @param Customer $entity
  * @return bool
  */
 public function handleRegister(Customer $entity)
 {
     if ($this->request->getMethod() === 'POST') {
         $manager = $this->doctrineHelper->getEntityManager($entity);
         $entity->setGuest(false);
         $entity->setIsActive(true);
         $this->stateHandler->markCustomerForSync($entity);
         $this->stateHandler->markAddressesForSync($entity);
         $manager->persist($entity);
         $manager->flush();
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * @param array $item
  * @param Customer $entity
  */
 protected function writeNewItem(array $item, Customer $entity)
 {
     try {
         $customerId = $this->transport->createCustomer($item);
         $entity->setOriginId($customerId);
         $this->stateHandler->markCustomerSynced($entity);
         $this->stateHandler->markAddressesForSync($entity);
         $this->logger->info(sprintf('Customer with id %s successfully created with data %s', $customerId, json_encode($item)));
         $entity->setCreatedAt(new \DateTime('now', new \DateTimeZone('UTC')));
         $entity->setUpdatedAt($entity->getCreatedAt());
     } catch (\Exception $e) {
         $this->logger->error($e->getMessage());
         $this->stepExecution->addFailureException($e);
     }
 }