I have services in my services.xml
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
</service>
<service id="my.main" class="%my.main.class%">
    <call method="foo">
        <argument type="service" id="tmcyc.connection" />
    </call>
</service>
But got error:
Catchable Fatal Error: Argument 1 passed to Doctrine\Bundle\DoctrineBundle\ ConnectionFactory::__construct() must be an array, none given...
How can I pass array with argument? For example:
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
    <argument>[ARRAY]</argument>
</service>
or maybe I'm doing somthing wrong? Because this code works greate:
$connectionFactory = $this->getContainer()->get('doctrine.dbal.connection_factory');
$conn = $this->createConnection($this->conn);
$conn->executeQuery('SET NAMES utf8');
                Еhis example should clarify the principle:
In *.yml
some_id: 
    class: %some.class%
    arguments: 
        - %some.argument%, 
        - [tags: [environment: %kernel.environment%, debug:%kernel.debug%]]
In *.xml
<service id="some_id" class="%some.class%">
    <argument>%some.argument%</argument>
    <argument type="collection">
        <argument key="tags" type="collection">
            <argument key="environment">%kernel.environment%</argument>
            <argument key="debug">%kernel.debug%</argument>
        </argument>
    </argument>
</service>
                        Ok, found the answer
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
    <argument>%doctrine.dbal.connection_factory.types%</argument>
</service>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With