/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(['choices' => function (Options $options) { if (null === $options['customer']) { return $this->addressRepository->findAll(); } return $this->addressRepository->findBy(['customer' => $options['customer']]); }, 'choice_value' => 'id', 'choice_translation_domain' => false, 'customer' => null, 'label' => false, 'placeholder' => false]); }
/** * @Given /^(my) default address is of "([^"]+)"$/ */ public function myDefaultAddressIsOf(ShopUserInterface $user, $fullName) { list($firstName, $lastName) = explode(' ', $fullName); /** @var AddressInterface $address */ $address = $this->addressRepository->findOneBy(['firstName' => $firstName, 'lastName' => $lastName]); Assert::notNull($address, sprintf('The address of "%s" has not been found.', $fullName)); /** @var CustomerInterface $customer */ $customer = $user->getCustomer(); $this->setDefaultAddressOfCustomer($customer, $address); }
/** * @Transform /^"([^"]+)" street$/ */ public function getByStreet($street) { $address = $this->addressRepository->findOneBy(['street' => $street]); Assert::notNull($address, sprintf('Cannot find address by %s street.', $street)); return $address; }