本文整理汇总了PHP中Sylius\Component\Resource\Repository\RepositoryInterface::findOneBy方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface::findOneBy方法的具体用法?PHP RepositoryInterface::findOneBy怎么用?PHP RepositoryInterface::findOneBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Repository\RepositoryInterface
的用法示例。
在下文中一共展示了RepositoryInterface::findOneBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActivedProvider
/**
* @return null|ProviderInterface
*/
public function getActivedProvider()
{
if ($provider = $this->repository->findOneBy(array('actived' => true))) {
return $provider;
}
return $this->findByName($this->defaultProvider);
}
示例2: validate
/**
* {@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);
}
}
示例3: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($code)
{
if (null === $code || '' === $code) {
return null;
}
return $this->promotionCouponRepository->findOneBy(['code' => $code]);
}
示例4: getPermission
/**
* {@inheritdoc}
*/
public function getPermission($code)
{
if (null === ($permission = $this->repository->findOneBy(array('code' => $code)))) {
throw new PermissionNotFoundException($code);
}
return $permission;
}
示例5: getCountryByName
/**
* @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;
}
示例6: iAddedProductToTheCart
/**
* @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();
}
示例7: execute
/**
* {@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));
}
示例8: update
/**
* {@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());
}
示例9: getCurrency
private function getCurrency($code)
{
if (isset($this->cache[$code])) {
return $this->cache[$code];
}
return $this->cache[$code] = $this->currencyRepository->findOneBy(array('code' => $code));
}
示例10: isUsedCode
/**
* @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;
}
示例11: getCurrency
/**
* @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]);
}
示例12:
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);
}
示例13: castProductNameToProduct
/**
* @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;
}
示例14: getZoneByCode
/**
* @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;
}
示例15: getTaxRateByName
/**
* @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;
}