user2559108
user2559108

Reputation:

Passing an instantiated object to a service via the constructer

I want to pass an initated object to a service, i want that instance of the object, i also want to set the object in a property so i can retreieve it afterwards, hence why i am passing it in the constructor.

Here is my services.yml

services:
    LoginService:
        class: Snap\ModelBundle\Service\Login
        arguments: ["@doctrine.orm.entity_manager", "@ExampleModelBundle.lib.Example.Ex"]

The second augment does not get passed, it gets passed a string path.

How do i pass the second augment which is an object?

Upvotes: 1

Views: 66

Answers (1)

qooplmao
qooplmao

Reputation: 17759

You can create a service just for the class like..

instance.of.class:
    class: The\Class
    calls:  // if any.. or arguments..
        - [ setThing, [ blahblah ]]

and then it can be used as an argument as @instance.of.class

Upvotes: 1

Related Questions