/** * @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]); }
/** * {@inheritdoc} */ public function getPermission($code) { if (null === ($permission = $this->repository->findOneBy(array('code' => $code)))) { throw new PermissionNotFoundException($code); } return $permission; }
/** * @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; }
/** * @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(); }
/** * {@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()); }
private function getCurrency($code) { if (isset($this->cache[$code])) { return $this->cache[$code]; } return $this->cache[$code] = $this->currencyRepository->findOneBy(array('code' => $code)); }
/** * @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; }
/** * @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); }
/** * @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; }
/** * @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; }
/** * @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; }
/** * {@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); }
/** * @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); }
/** * @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; }
/** * @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; }
/** * @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; }
/** * @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; }
/** * @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; }
/** * {@inheritdoc} */ public function getEmail($code) { $email = $this->emailRepository->findOneBy(array('code' => $code)); if (null === $email) { $email = $this->getEmailFromConfiguration($code); } return $email; }
/** * @param string $taxCategoryName * * @return TaxCategoryInterface */ private function getOrCreateTaxCategory($taxCategoryName) { $taxCategory = $this->taxCategoryRepository->findOneBy(['name' => $taxCategoryName]); if (null === $taxCategory) { $taxCategory = $this->createTaxCategory($taxCategoryName); } return $taxCategory; }
/** * @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()); }
/** * @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; }
/** * @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; }
/** * @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; }