Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 5 column 21
---
title: Add support for autowiring of entity repositories
issue: NEXT-10918
author: Hendrik Söbbing
author_email: [email protected]
author_github: @soebbing
---
- Changed
\Shopware\Core\Framework\DependencyInjection\CompilerPass\EntityCompilerPass
to also register an alias for arguments
The DAL entity repositories can now be injected into your services using autowiring. Necessary for this to work (apart from having your service configured for autowiring generally) are:
- The type of the parameter. It needs to be
EntityRepositoryInterface
- The name of the variable. It must be the same as the id of the service in the DIC, written in
camelCase
instead ofsnake_case
, followed by the wordRepository
.
So for example, a media_thumbnail repository (id media_thumbnail.repository
) would be requested (and injected) like this:
public function __construct(EntityRepositoryInterface $mediaThumbnailRepository) {}