0

I want to be able to use $this->container in class below but how do I pass container to it with yml below? Or do I really need to pass it to access $this->container->getParameter('currency'); ? I did all the others as the example shows but failing to pass the container!

Thanks in advance

I have this code in config.yml:

services:
    data_cash:
            class:        Booking\FrontendBundle\WebService\CashManager
            arguments:    [@doctrine.orm.entity_manager, %paymentCallback%, %kernel.environment%]

This is the CashManager class:

class CashManager
{
    public function __construct($entityManager, $callback, $environment, $CONTAINER)
    {
        //$this->currency = $CONTAINER->getParameter('currency');
    }
}

1 Answer 1

1

It is a bad idea to pass the entire container, but you have to add this in arguments: @service_container .

If you what only the parameter "currency" you have to add this: %currency%

Sign up to request clarification or add additional context in comments.

3 Comments

OK. How can I make it better?
I only need this: $this->container->getParameter('currency'); so how do I only inject that?
Learner something new. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.