webgriffe/SyliusAkeneoPlugin

Error while installing the plugin

Closed this issue · 4 comments

If one tries to install the plugin using composer require as indicated in the documentation with the Symfony Flex enabled, then the following error is generated:

The service "webgriffe_sylius_akeneo.command.queue_cleanup" has a dependency on a non-existent service "webgriffe_sylius_akeneo.manager.queue_item".

As a workaround, one can manually execute steps 2 and 3 of the installation guide, which should solve the problem. But still it would be nice to have the installation succeed without having to do this.

This is because the step 2 of the installation is done automatically by Symfony Flex but not the step 3.
So just after the composer require webgriffe/sylius-akeneo-plugin you have the plugin enabled but without its configuration which define the webgriffe_sylius_akeneo.queue_item resource which in turns defines the webgriffe_sylius_akeneo.manager.queue_item service.

Anyway as you say it would be nice to have the installation succeed without error.

I don't know why but it appears that before importing the plugin configuration, the service webgriffe_sylius_akeneo.manager.queue_item does not exists but the service webgriffe_sylius_akeneo_plugin.manager.queue_item does. And both are aliases of doctrine.orm.default_entity_manager.

So a possible fix to this issue is to replace this in src/Resources/config/services.xml:

        <service id="webgriffe_sylius_akeneo_plugin.repository.cleanable_queue_item" class="Webgriffe\SyliusAkeneoPlugin\Doctrine\ORM\QueueItemRepository">
            <argument type="service" id="webgriffe_sylius_akeneo.manager.queue_item" />
            <argument type="service">
                <service class="Doctrine\ORM\Mapping\ClassMetadata" public="false" >
                    <factory service="webgriffe_sylius_akeneo_plugin.manager.queue_item" method="getClassMetadata" />
                    <argument type="string">Webgriffe\SyliusAkeneoPlugin\Entity\QueueItem</argument>
                </service>
            </argument>
        </service>

with this:

        <service id="webgriffe_sylius_akeneo_plugin.repository.cleanable_queue_item" class="Webgriffe\SyliusAkeneoPlugin\Doctrine\ORM\QueueItemRepository">
            <argument type="service" id="webgriffe_sylius_akeneo_plugin.manager.queue_item" />
            <argument type="service">
                <service class="Doctrine\ORM\Mapping\ClassMetadata" public="false" >
                    <factory service="webgriffe_sylius_akeneo_plugin.manager.queue_item" method="getClassMetadata" />
                    <argument type="string">Webgriffe\SyliusAkeneoPlugin\Entity\QueueItem</argument>
                </service>
            </argument>
        </service>

The question is: who is defining the webgriffe_sylius_akeneo_plugin.manager.queue_item alias even before importing the configuration of the queue_item resource into the Sylius Resource Bundle?

The question is: who is defining the webgriffe_sylius_akeneo_plugin.manager.queue_item alias even before importing the configuration of the queue_item resource into the Sylius Resource Bundle?

Answer: https://github.com/webgriffe/SyliusAkeneoPlugin/blob/master/src/DependencyInjection/WebgriffeSyliusAkeneoExtension.php#L106

This has been solved with #43, closing.