Exemple #1
0
 /**
  * @Transform /^this order made by "([^"]+)"$/
  * @Transform /^order placed by "([^"]+)"$/
  * @Transform /^the order of "([^"]+)"$/
  */
 public function getOrderByCustomer($email)
 {
     $customer = $this->customerRepository->findOneBy(['email' => $email]);
     Assert::notNull($customer, sprintf('Cannot find customer with email %s.', $email));
     $orders = $this->orderRepository->findByCustomer($customer);
     Assert::notEmpty($orders);
     return end($orders);
 }
Exemple #2
0
 /**
  * @Transform :customer
  * @Transform /^customer "([^"]+)"$/
  */
 public function getOrCreateCustomerByEmail($email)
 {
     /** @var CustomerInterface $customer */
     $customer = $this->customerRepository->findOneBy(['email' => $email]);
     if (null === $customer) {
         $customer = $this->customerFactory->createNew();
         $customer->setEmail($email);
         $this->customerRepository->add($customer);
     }
     return $customer;
 }