-- macest <[email protected]> wrote
(on Friday, 16 March 2012, 06:28 AM -0700):
> I'm trying to use a native class (SphinxClient installed via PECL) with the
> dependency injector to set the server:
> 
> 'definition' => array(
>       'class' => array(
>               'SphinxClient' => array(
>                       'methods' => array(
>                               'setServer' => array(

add a 

    "required" => true 

at the method level, and it will force it to be injected.

One thing I've noticed is that a lot of pecl extensions do not do
reflection properly, which makes it necessary to do these definitions.
Bug the extension authors to do it correctly (I did this with Mongo, and
it now has decent reflection).

>                                       'host' => array(
>                                               'type' => false,
>                                               'required' => true
>                                       ),
>                                       'port' => array(
>                                               'type' => false,
>                                               'required' => true
>                                       ),
>                               ),
>                       ),
>               ),
>       ),
> ),
> 'instance' => array(
>       'SphinxClient' => array(
>               'injections' => array(
>                       'setServer' => array(
>                               'host' => 'localhost',
>                               'port' => 3312,
>                       ),
>               ),
>       ),
> ),
> 
> This does not work seem to work, the method is not called. however if I
> simply extend it with my own empty class it does.
> 
> 'definition' => array(
>       'class' => array(
>               'My\SphinxClient' => array(
>                       'methods' => array(
>                               'setServer' => array(
>                                       'host' => array(
>                                               'type' => false,
>                                               'required' => true
>                                       ),
>                                       'port' => array(
>                                               'type' => false,
>                                               'required' => true
>                                       ),
>                               ),
>                       ),
>               ),
>       ),
> ),
> 'instance' => array(
>       'My\SphinxClient' => array(
>               'injections' => array(
>                       'setServer' => array(
>                               'host' => 'localhost',
>                               'port' => 3312,
>                       ),
>               ),
>       ),
> ),
> 
> Why won't it work with the native class?
> 
> --
> View this message in context: 
> http://zend-framework-community.634137.n4.nabble.com/DI-and-native-classes-tp4478165p4478165.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 
> -- 
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
> 
> 

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to