/**
  * @return null|ProviderInterface
  */
 public function getActivedProvider()
 {
     if ($provider = $this->repository->findOneBy(array('actived' => true))) {
         return $provider;
     }
     return $this->findByName($this->defaultProvider);
 }
 /**
  * {@inheritdoc}
  */
 public function validate($customer, Constraint $constraint)
 {
     $existingCustomer = $this->customerRepository->findOneBy(['email' => $customer->getEmail()]);
     if (null !== $existingCustomer && null !== $existingCustomer->getUser()) {
         $this->context->addViolationAt('email', $constraint->message, [], null);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function reverseTransform($code)
 {
     if (null === $code || '' === $code) {
         return null;
     }
     return $this->promotionCouponRepository->findOneBy(['code' => $code]);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function getPermission($code)
 {
     if (null === ($permission = $this->repository->findOneBy(array('code' => $code)))) {
         throw new PermissionNotFoundException($code);
     }
     return $permission;
 }
Example #5
0
 /**
  * @Transform /^country "([^"]+)"$/
  * @Transform /^"([^"]+)" country$/
  * @Transform /^"([^"]+)" as shipping country$/
  */
 public function getCountryByName($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $country = $this->countryRepository->findOneBy(['code' => $countryCode]);
     Assert::notNull($country, sprintf('Country with name "%s" does not exist', $countryName));
     return $country;
 }
Example #6
0
 /**
  * @Given I added product :name to the cart
  */
 public function iAddedProductToTheCart($name)
 {
     /** @var ProductInterface $product */
     $product = $this->productRepository->findOneBy(array('name' => $name));
     $productShowPage = $this->getPage('Product\\ProductShowPage')->openSpecificProductPage($product);
     $productShowPage->addToCart();
 }
Example #7
0
 /**
  * {@inheritDoc}
  *
  * @param $request Notify
  */
 public function execute($request)
 {
     if (!$this->supports($request)) {
         throw RequestNotSupportedException::createActionNotSupported($this, $request);
     }
     $this->payment->execute($httpRequest = new GetHttpRequest());
     $details = $httpRequest->query;
     if (!$this->api->verifyHash($details)) {
         throw new BadRequestHttpException('Hash cannot be verified.');
     }
     if (empty($details['ORDERID'])) {
         throw new BadRequestHttpException('Order id cannot be guessed');
     }
     $payment = $this->paymentRepository->findOneBy(array($this->identifier => $details['ORDERID']));
     if (null === $payment) {
         throw new BadRequestHttpException('Payment cannot be retrieved.');
     }
     if ((int) $details['AMOUNT'] !== $payment->getAmount()) {
         throw new BadRequestHttpException('Request amount cannot be verified against payment amount.');
     }
     // Actually update payment details
     $details = array_merge($payment->getDetails(), $details);
     $payment->setDetails($details);
     $status = new GetStatus($payment);
     $this->payment->execute($status);
     $nextState = $status->getValue();
     $this->updatePaymentState($payment, $nextState);
     $this->objectManager->flush();
     throw new HttpResponse(new Response('OK', 200));
 }
 /**
  * {@inheritdoc}
  */
 public function update(OrderInterface $order)
 {
     /** @var CurrencyInterface $currency */
     $currency = $this->currencyRepository->findOneBy(['code' => $this->currencyContext->getCurrencyCode()]);
     $order->setCurrencyCode($currency->getCode());
     $order->setExchangeRate($currency->getExchangeRate());
 }
Example #9
0
 private function getCurrency($code)
 {
     if (isset($this->cache[$code])) {
         return $this->cache[$code];
     }
     return $this->cache[$code] = $this->currencyRepository->findOneBy(array('code' => $code));
 }
Example #10
0
 /**
  * @param string $token
  *
  * @return Boolean
  */
 protected function isUsedCode($token)
 {
     $this->manager->getFilters()->disable('softdeleteable');
     $isUsed = null !== $this->repository->findOneBy(array('confirmationToken' => $token));
     $this->manager->getFilters()->enable('softdeleteable');
     return $isUsed;
 }
Example #11
0
 /**
  * @param string $code
  *
  * @return CurrencyInterface
  */
 protected function getCurrency($code)
 {
     if (isset($this->cache[$code])) {
         return $this->cache[$code];
     }
     return $this->cache[$code] = $this->currencyRepository->findOneBy(['code' => $code]);
 }
 function it_returns_null_if_metadata_is_not_found(RepositoryInterface $metadataContainerRepository, MetadataCompilerInterface $metadataCompiler, MetadataHierarchyProviderInterface $metadataHierarchyProvider, MetadataSubjectInterface $metadataSubject)
 {
     $metadataHierarchyProvider->getHierarchyByMetadataSubject($metadataSubject)->shouldBeCalled()->willReturn(['MetadataSubject-42', 'MetadataSubject']);
     $metadataContainerRepository->findOneBy(['id' => 'MetadataSubject-42'])->shouldBeCalled()->willReturn(null);
     $metadataContainerRepository->findOneBy(['id' => 'MetadataSubject'])->shouldBeCalled()->willReturn(null);
     $metadataCompiler->compile(Argument::cetera())->shouldNotBeCalled();
     $this->findMetadataBySubject($metadataSubject)->shouldReturn(null);
 }
Example #13
0
 /**
  * @Transform /^product "([^"]+)"$/
  * @Transform /^"([^"]+)" product$/
  */
 public function castProductNameToProduct($productName)
 {
     $product = $this->productRepository->findOneBy(['name' => $productName]);
     if (null === $product) {
         throw new \InvalidArgumentException('Product with name "' . $productName . '" does not exist');
     }
     return $product;
 }
Example #14
0
 /**
  * @Transform :zone zone
  * @Transform zone :zone
  */
 public function getZoneByCode($zone)
 {
     $existingZone = $this->zoneRepository->findOneBy(['code' => $zone]);
     if (null === $existingZone) {
         throw new \InvalidArgumentException(sprintf('Zone with code "%s" does not exist', $zone));
     }
     return $existingZone;
 }
Example #15
0
 /**
  * @Transform :taxRate
  */
 public function getTaxRateByName($taxRateName)
 {
     $taxRate = $this->taxRateRepository->findOneBy(['name' => $taxRateName]);
     if (null === $taxRate) {
         throw new \InvalidArgumentException(sprintf('Tax rate with name "%s" does not exist.', $taxRateName));
     }
     return $taxRate;
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function resolve(TaxableInterface $taxable, array $criteria = [])
 {
     if (null === ($category = $taxable->getTaxCategory())) {
         return null;
     }
     $criteria = array_merge(['category' => $category], $criteria);
     return $this->taxRateRepository->findOneBy($criteria);
 }
Example #17
0
 /**
  * @Given the store has route :name with :contentTitle as its content
  */
 public function theStoreHasRouteWithAsItsContent($name, $contentTitle)
 {
     $content = $this->staticContentRepository->findOneBy(['title' => $contentTitle]);
     $route = $this->routeExampleFactory->create(['name' => $name, 'content' => $content]);
     $this->routeManager->persist($route);
     $this->routeManager->flush();
     $this->sharedStorage->set('route', $route);
 }
Example #18
0
 /**
  * @Transform /^"([^"]+)" tax category$/
  * @Transform /^tax category "([^"]+)"$/
  */
 public function castTaxCategoryNameToTaxCategory($taxCategoryName)
 {
     $taxCategory = $this->taxCategoryRepository->findOneBy(['name' => $taxCategoryName]);
     if (null === $taxCategory) {
         throw new \Exception('Tax category with name "' . $taxCategoryName . '" does not exist');
     }
     return $taxCategory;
 }
Example #19
0
 /**
  * @Transform /^rest of the world$/
  * @Transform /^the rest of the world$/
  */
 public function getRestOfTheWorldZone()
 {
     $zone = $this->zoneRepository->findOneBy(['code' => 'RoW']);
     if (null === $zone) {
         throw new \Exception('Rest of the world zone does not exist.');
     }
     return $zone;
 }
Example #20
0
 /**
  * @Transform /^coupon "([^"]+)"$/
  * @Transform /^"([^"]+)" coupon$/
  * @Transform :coupon
  */
 public function getCouponByCode($couponCode)
 {
     $coupon = $this->couponRepository->findOneBy(['code' => $couponCode]);
     if (null === $coupon) {
         throw new \InvalidArgumentException(sprintf('Coupon with code "%s" does not exist in the coupon repository.', $couponCode));
     }
     return $coupon;
 }
Example #21
0
 /**
  * @Transform /^"([^"]+)" payment$/
  */
 public function getPaymentMethodByName($paymentMethodName)
 {
     $paymentMethod = $this->paymentMethodRepository->findOneBy(['name' => $paymentMethodName]);
     if (null === $paymentMethod) {
         throw new \InvalidArgumentException(sprintf('Payment method with name "%s" does not exist.', $paymentMethodName));
     }
     return $paymentMethod;
 }
Example #22
0
 /**
  * @Transform :shippingMethodName shipping method
  * @Transform shipping method :shippingMethodName
  */
 public function getShippingMethodByName($shippingMethodName)
 {
     $shippingMethod = $this->shippingMethodRepository->findOneBy(['name' => $shippingMethodName]);
     if (null === $shippingMethod) {
         throw new \Exception('Shipping method with name "' . $shippingMethodName . '" does not exist');
     }
     return $shippingMethod;
 }
Example #23
0
 /**
  * {@inheritdoc}
  */
 public function getEmail($code)
 {
     $email = $this->emailRepository->findOneBy(array('code' => $code));
     if (null === $email) {
         $email = $this->getEmailFromConfiguration($code);
     }
     return $email;
 }
Example #24
0
 /**
  * @param string $taxCategoryName
  *
  * @return TaxCategoryInterface
  */
 private function getOrCreateTaxCategory($taxCategoryName)
 {
     $taxCategory = $this->taxCategoryRepository->findOneBy(['name' => $taxCategoryName]);
     if (null === $taxCategory) {
         $taxCategory = $this->createTaxCategory($taxCategoryName);
     }
     return $taxCategory;
 }
Example #25
0
 /**
  * @Transform /^"([^"]+)" tax category$/
  * @Transform /^tax category "([^"]+)"$/
  */
 public function getTaxCategoryByName($taxCategoryName)
 {
     $taxCategory = $this->taxCategoryRepository->findOneBy(['name' => $taxCategoryName]);
     if (null === $taxCategory) {
         throw new \InvalidArgumentException('Tax category with name "' . $taxCategoryName . '" does not exist');
     }
     return $taxCategory;
 }
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  */
 public function update(OrderInterface $order)
 {
     $currencyCode = $order->getCurrencyCode();
     /** @var CurrencyInterface $currency */
     $currency = $this->currencyRepository->findOneBy(['code' => $currencyCode]);
     Assert::notNull($currency);
     $order->setExchangeRate($currency->getExchangeRate());
 }
Example #27
0
 /**
  * @Transform /^"([^"]+)" variant of product "([^"]+)"$/
  */
 public function getProductVariantByNameAndProduct($variantName, $productName)
 {
     $product = $this->getProductByName($productName);
     $productVariant = $this->productVariantRepository->findOneBy(['presentation' => $variantName, 'object' => $product]);
     if (null === $productVariant) {
         throw new \InvalidArgumentException(sprintf('Product variant with name "%s" of product "%s" does not exist', $variantName, $productName));
     }
     return $productVariant;
 }
Example #28
0
 /**
  * @param string $code
  *
  * @throws \InvalidArgumentException
  *
  * @return ProvinceInterface
  */
 private function getProvince($code)
 {
     /** @var ProvinceInterface $province */
     $province = $this->provinceRepository->findOneBy(array('code' => $code));
     if (null === $province) {
         throw new \InvalidArgumentException(sprintf('Province with code "%s" not found.', $code));
     }
     return $province;
 }
 /**
  * @return OrderSequenceInterface
  */
 private function getSequence()
 {
     $sequence = $this->sequenceRepository->findOneBy([]);
     if (null === $sequence) {
         $sequence = $this->sequenceFactory->createNew();
         $this->sequenceRepository->add($sequence);
     }
     return $sequence;
 }
Example #30
0
 /**
  * @Transform /^country "([^"]+)"$/
  * @Transform /^"([^"]+)" country$/
  */
 public function getCountryByName($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $country = $this->countryRepository->findOneBy(['code' => $countryCode]);
     if (null === $country) {
         throw new \InvalidArgumentException(sprintf('Country with name %s does not exist', $countryName));
     }
     return $country;
 }