Since yesterday, I can't understand why i have this error on my Symfony website. I have a service which depends on others. When i try to use and inject the Symfony doctrine entity manager i have errors. I can't find a way to do it :(
My config :
mycompany_jobs_bundle.processor.crm.product_matrix:
class: %mycompany_jobs_bundle.processor.crm.product_matrix.class%
parent: pim_base_connector.processor.product_to_flat_array
arguments:
- '@pim_catalog.repository.attribute'
- '@pim_catalog.localization.factory.date'
- '@doctrine.orm.default_entity_manager'
(I also tried 'doctrine.orm.entity_manager' instead of '@doctrine.orm.default_entity_manager' -> same results)
Then, in my service :
... but i have this error :
Catchable Fatal Error: Argument 8 passed to Mycompany\Bundle\JobsBundle\Processor\Mycompany\ProductWordMatrixProcessor::__construct() must implement interface Pim\Component\Catalog\Repository\AttributeRepositoryInterface, instance of Doctrine\ORM\EntityManager given
Wherever i move my line "EntityManager $em" i have error with arguments position. What's wrong ? I can't understand ..
Thanks for your help
Edit : below the yml config of the parent service, pim_base_connector.processor.product_to_flat_array :
pim_base_connector.processor.product_to_flat_array: class: %pim_base_connector.processor.product_to_flat_array.class% arguments: - '@pim_serializer' - '@pim_catalog.manager.channel' - '@pim_catalog.builder.product' - ['pim_catalog_file', 'pim_catalog_image'] - %pim_catalog.localization.decimal_separators% - %pim_catalog.localization.date_formats% - '@akeneo_storage_utils.doctrine.object_detacher'
Try to move the EntityManaer as the last parameter of your constructor arguments like this:
public function __construct()
{
//.. others
AttributeRepositoryInterface $attributeRepository,
EntityManager $em
}
You need to maintain the order of your dependencies declared inside the configuration
You constructor has 10 arguments and all of them should be configured. You specified only 7. You have to specify last 3 as well and check the order. It's important.