本文整理汇总了PHP中Sylius\Component\Resource\Repository\RepositoryInterface::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface::findBy方法的具体用法?PHP RepositoryInterface::findBy怎么用?PHP RepositoryInterface::findBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Repository\RepositoryInterface
的用法示例。
在下文中一共展示了RepositoryInterface::findBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableCurrenciesCodes
/**
* {@inheritdoc}
*/
public function getAvailableCurrenciesCodes()
{
$currencies = $this->currencyRepository->findBy(['enabled' => true]);
return array_map(function (CurrencyInterface $currency) {
return $currency->getCode();
}, $currencies);
}
示例2: getAvailableLocalesCodes
/**
* {@inheritdoc}
*/
public function getAvailableLocalesCodes()
{
$locales = $this->localeRepository->findBy(['enabled' => true]);
return array_map(function (LocaleInterface $locale) {
return $locale->getCode();
}, $locales);
}
示例3: getZones
/**
* @param array $options
*
* @return array
*/
private function getZones(array $options)
{
if (isset($options['scope'])) {
return $this->zoneRepository->findBy(['scope' => $options['scope']]);
}
return $this->zoneRepository->findAll();
}
示例4: getCart
public function getCart()
{
$user = $this->getUser();
$carts = $this->cartRepository->findBy(['user' => $user, 'expiresAt' => null, 'state' => 'cart'], ['createdAt' => 'DESC'], 1);
if (count($carts)) {
return $carts[0];
}
return null;
}
示例5: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(['choices' => function (Options $options) {
if (null === $options['enabled']) {
return $this->countryRepository->findAll();
}
return $this->countryRepository->findBy(['enabled' => $options['enabled']]);
}, 'choice_value' => 'code', 'choice_label' => 'name', 'choice_translation_domain' => false, 'enabled' => true, 'label' => 'sylius.form.address.country', 'placeholder' => 'sylius.form.country.select']);
}
示例6: getEnabledLocalesCodes
/**
* @return string[]
*/
protected function getEnabledLocalesCodes()
{
$localesCodes = array();
/** @var LocaleInterface[] $locales */
$locales = $this->localeRepository->findBy(array('enabled' => true));
foreach ($locales as $locale) {
$localesCodes[] = $locale->getCode();
}
return $localesCodes;
}
示例7: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choices = function (Options $options) {
if (null === $options['customer']) {
return $this->addressRepository->findAll();
}
return $this->addressRepository->findBy(['customer' => $options['customer']]);
};
$resolver->setDefaults(['class' => AddressInterface::class, 'choices' => $choices, 'customer' => null, 'label' => false, 'placeholder' => false]);
}
示例8: getAvailableLocales
/**
* @return array
*/
public function getAvailableLocales()
{
$localesCodes = [];
/** @var LocaleInterface[] $locales */
$locales = $this->localeRepository->findBy(['enabled' => true]);
foreach ($locales as $locale) {
$localesCodes[] = $locale->getCode();
}
return $localesCodes;
}
示例9: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choices = [];
/** @var CurrencyInterface[] $currencies */
$currencies = $this->currencyRepository->findBy(['enabled' => true]);
foreach ($currencies as $currency) {
$choices[$currency->getCode()] = sprintf('%s - %s', $currency->getCode(), $currency->getName());
}
$resolver->setDefaults(['choice_translation_domain' => false, 'choices' => $choices]);
}
示例10: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(['choices' => function (Options $options) {
if (null === $options['enabled']) {
return $this->localeRepository->findAll();
}
return $this->localeRepository->findBy(['enabled' => $options['enabled']]);
}, 'choice_value' => 'code', 'choice_label' => 'name', 'choice_translation_domain' => false, 'enabled' => null, 'label' => 'sylius.form.locale.locale', 'placeholder' => 'sylius.form.locale.select']);
}
示例11: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choices = function (Options $options) {
if (null === $options['enabled']) {
$countries = $this->countryRepository->findAll();
} else {
$countries = $this->countryRepository->findBy(['enabled' => $options['enabled']]);
}
return $this->getCountryCodes($countries);
};
$resolver->setDefaults(['choices' => $choices, 'choices_as_values' => true, 'enabled' => true, 'label' => 'sylius.form.address.country', 'empty_value' => 'sylius.form.country.select']);
}
示例12: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choices = function (Options $options) {
if (null === $options['enabled']) {
$choices = $this->countryRepository->findAll();
} else {
$choices = $this->countryRepository->findBy(['enabled' => $options['enabled']]);
}
return new ArrayChoiceList($choices);
};
$resolver->setDefaults(['choice_translation_domain' => false, 'choice_list' => $choices, 'enabled' => true, 'label' => 'sylius.form.address.country', 'empty_value' => 'sylius.form.country.select']);
}
示例13: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choiceList = function (Options $options) {
if (isset($options['subject'])) {
$methods = $this->resolver->getSupportedMethods($options['subject'], $options['criteria']);
} else {
$methods = $this->repository->findBy($options['criteria']);
}
return new ObjectChoiceList($methods, null, [], null, 'id');
};
$resolver->setDefaults(['choice_list' => $choiceList, 'criteria' => []])->setDefined(['subject'])->setAllowedTypes('subject', ShippingSubjectInterface::class)->setAllowedTypes('criteria', 'array');
}
示例14: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$choiceList = function (Options $options) {
if (null === $options['enabled']) {
$choices = $this->localeRepository->findAll();
} else {
$choices = $this->localeRepository->findBy(array('enabled' => $options['enabled']));
}
return new ObjectChoiceList($choices, null, array(), null, 'id');
};
$resolver->setDefaults(array('choice_list' => $choiceList, 'enabled' => null, 'label' => 'sylius.form.locale.locale', 'empty_value' => 'sylius.form.locale.select'));
}
示例15: generateNumber
private function generateNumber()
{
/** @var OrderInterface[] $orders */
$orders = $this->orderRepository->findBy([], ['createdAt' => 'DESC'], 1);
if (count($orders)) {
$number = $orders[0]->getNumber();
if ($number !== null) {
$number++;
return $number;
}
}
return 1;
}