function it_does_not_support_subject_if_none_of_resolvers_from_registry_supports_it(MethodsResolverInterface $firstMethodsResolver, MethodsResolverInterface $secondMethodsResolver, PrioritizedServiceRegistryInterface $resolversRegistry, ShippingSubjectInterface $shippingSubject) { $resolversRegistry->all()->willReturn([$firstMethodsResolver, $secondMethodsResolver]); $firstMethodsResolver->supports($shippingSubject)->willReturn(false); $firstMethodsResolver->supports($shippingSubject)->willReturn(false); $this->supports($shippingSubject)->shouldReturn(false); }
/** * {@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'); }