2

I was following the tutorials on https://apigility.org/documentation/content-validation/basic-usage. But, when I tried to inject the input filter service AddressBook\V1\Rest\Contact\Validator in the ContactResource, I get the following error:

Zend\ServiceManager\Exception\ServiceNotFoundException File: /Users/.../src/apigility-tutorials/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529 Message: Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for AddressBook\V1\Rest\Contact\Validator

I am not sure if it's an issue with apigility itself, this is why i'm asking if the example shown in the link above actually works when using dependency injection. Thanks

Nekapps
  • 53
  • 4
  • Did you actually register an `InputFilter` with that name in your `InputFilterManager` or did you create `input_filter_specs` for a input filter with that name as a key? – Wilt Oct 13 '14 at 09:06
  • @Wilt I used the apigility-admin interface to create this Contact REST service. I can confirm that it did create an input_filter_specs for Contact. – Nekapps Oct 13 '14 at 09:16
  • I read your question once more. What do you actually want to achieve? Why inject the `InputFilter` in the `ContactResource`? – Wilt Oct 13 '14 at 09:22
  • @Wilt I was just following the tutorial on apigility documentation to set an example for my problem. My problem is that I cannot get the inputFilter service to work by calling `$service->get('AddressBook\V1\Rest\Contact\Validator')` in ContactResource or elsewhere. – Nekapps Oct 13 '14 at 09:50

1 Answers1

1

Got it. According to the zf-content-validation doc, the input filter is registered through Zend\InputFilter\InputFilterPluginManager which means I have to get the InputFilterManager service first then get the Contact input filter service as follows:

$inputFilter = $serviceLocator->get('InputFilterManager') ->get('AddressBook\V1\Rest\Contact\Validator');

Thanks for looking into it.

Nekapps
  • 53
  • 4