コード例 #1
0
ファイル: OrderContext.php プロジェクト: sylius/sylius
 /**
  * @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);
 }
コード例 #2
0
ファイル: CustomerContext.php プロジェクト: sylius/sylius
 /**
  * @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;
 }