nelmio / alice

Expressive fixtures generator
MIT License
2.49k stars 330 forks source link

Add support for autowiring #711

Open theofidry opened 7 years ago

theofidry commented 7 years ago

Adding support for autowiring would be a nice feature IMO with the coming Symfony 3.3. release. Plus making it work on the bundle would pave the way for adding a support for Laravel.

theofidry commented 6 years ago

To make this clearer: right now we have the following:

        <service id="nelmio_alice.data_loader" public="true"
                 alias="nelmio_alice.data_loader.simple" />

        <service id="nelmio_alice.data_loader.simple"
                 class="Nelmio\Alice\Loader\SimpleDataLoader">
            <argument type="service" id="nelmio_alice.fixture_builder" />
            <argument type="service" id="nelmio_alice.generator" />
        </service>

Instead we should have:


        <service id="Nelmio\Alice\DataLoaderInterface" public="true"
                 alias="nelmio_alice.data_loader.simple" />

        <service id="nelmio_alice.data_loader" public="true"
                 alias="Nelmio\Alice\DataLoaderInterface" />

        <service id="nelmio_alice.data_loader.simple"
                 class="Nelmio\Alice\Loader\SimpleDataLoader">
            <argument type="service" id="nelmio_alice.fixture_builder" />
            <argument type="service" id="nelmio_alice.generator" />
        </service>

/cc @greg0ire

theofidry commented 6 years ago

I'm not sure old services names should be deprecated, at least for now.

greg0ire commented 6 years ago

This would be cleaner IMO:

<!-- to be deprecated -->
<service id="nelmio_alice.data_loader"
    alias="Nelmio\Alice\Loader\SimpleDataLoader" />

<service id="nelmio_alice.data_loader.simple"
    alias="Nelmio\Alice\Loader\SimpleDataLoader" />

<!-- define default service for interface -->
<service id="Nelmio\Alice\DataLoaderInterface" public="true"
    alias="Nelmio\Alice\Loader\SimpleDataLoader" />

<service id="Nelmio\Alice\Loader\SimpleDataLoader"
    class="Nelmio\Alice\Loader\SimpleDataLoader">
    <argument type="service" id="nelmio_alice.fixture_builder" />
    <argument type="service" id="nelmio_alice.generator" />
</service>