[fw-core] DI configuration - passing class name instead of class instance

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[fw-core] DI configuration - passing class name instead of class instance

Piotr Dąbrowiecki
Hi everyone,

I want to setup factory class with object's class name (parameter), but I don't know
how to pass parameters to this class, because di container tries to instantiate the
parameter instead of passing string. Is there a way to "mark" a parameter to be treated
as string?

Regards,
Piotr Dabrowiecki
 

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


Reply | Threaded
Open this post in threaded view
|

Re: [fw-core] DI configuration - passing class name instead of class instance

Marco Pivetta
Hey Piotr,
You should tell Zend\Di that in the definition of your method, parameter type is 'false'. Check this one:

https://github.com/Ocramius/ZfMongoDbOdm/blob/master/configs/module.config.php#L32

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com



On 17 November 2011 13:44, Piotr Dąbrowiecki [via Zend Framework Community] <[hidden email]> wrote:
Hi everyone,

I want to setup factory class with object's class name (parameter), but I don't know
how to pass parameters to this class, because di container tries to instantiate the
parameter instead of passing string. Is there a way to "mark" a parameter to be treated
as string?

Regards,
Piotr Dabrowiecki
 

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





To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: [fw-core] DI configuration - passing class name instead of class instance

weierophinney
Administrator
In reply to this post by Piotr Dąbrowiecki
-- Piotr Dąbrowiecki <[hidden email]> wrote
(on Thursday, 17 November 2011, 01:44 PM +0100):
> I want to setup factory class with object's class name (parameter),
> but I don't know how to pass parameters to this class, because di
> container tries to instantiate the parameter instead of passing
> string. Is there a way to "mark" a parameter to be treated as string?

Since ZF2 is still in development, we recommend addressing ZF2 questions
to the zf-contributors mailing list -- you're more likely to reach the
developers there.

BTW, Marco's tip is correct.

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

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