Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions concepts/framework/data-abstraction-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ An EntityRepository is used to interact with the DAL. This is the recommended wa

### Provisioning code to use the repositories

Before using the repositories, you will need to get them from the [Dependency Injection Container (DIC)](../../guides/plugins/plugins/plugin-fundamentals/dependency-injection.md). This is done with [Constructor injection](https://symfony.com/doc/current/service_container/injection_types.html#constructor-injection), so you will need to extend your services constructor by expecting an EntityRepositoryInterface:
Before using the repositories, you will need to get them from the [Dependency Injection Container (DIC)](../../guides/plugins/plugins/plugin-fundamentals/dependency-injection.md). This is done with [Constructor injection](https://symfony.com/doc/current/service_container/injection_types.html#constructor-injection), so you will need to extend your services constructor by expecting an EntityRepository:

{% code title="<plugin root>/src/Service/DalExampleService.php" %}

```php
public function __construct (EntityRepositoryInterface $productRepository)
public function __construct (EntityRepository $productRepository)
{
$this->productRepository = $productRepository;
}
Expand Down
8 changes: 4 additions & 4 deletions guides/plugins/plugins/checkout/payment/add-payment-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ An example for your plugin could look like this:
namespace Swag\BasicExample;

use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Plugin;
Expand Down Expand Up @@ -445,14 +445,14 @@ class SwagBasicExample extends Plugin
'pluginId' => $pluginId,
];

/** @var EntityRepositoryInterface $paymentRepository */
/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');
$paymentRepository->create([$examplePaymentData], $context);
}

private function setPaymentMethodIsActive(bool $active, Context $context): void
{
/** @var EntityRepositoryInterface $paymentRepository */
/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');

$paymentMethodId = $this->getPaymentMethodId();
Expand All @@ -472,7 +472,7 @@ class SwagBasicExample extends Plugin

private function getPaymentMethodId(): ?string
{
/** @var EntityRepositoryInterface $paymentRepository */
/** @var EntityRepository $paymentRepository */
$paymentRepository = $this->container->get('payment_method.repository');

// Fetch ID for update
Expand Down
15 changes: 3 additions & 12 deletions guides/plugins/plugins/content/seo/add-custom-seo-url.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,32 +492,23 @@ use Cocur\Slugify\SlugifyInterface;
use Shopware\Core\Content\Seo\SeoUrlPersister;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;

class DynamicSeoUrlsService
{
public const ROUTE_NAME = 'example.route.name';

/**
* @var SeoUrlPersister
*/
private SeoUrlPersister $seoUrlPersister;

/**
* @var EntityRepositoryInterface
*/
private EntityRepositoryInterface $salesChannelRepository;
private EntityRepository $salesChannelRepository;

/**
* @var SlugifyInterface
*/
private SlugifyInterface $slugify;

public function __construct(
SeoUrlPersister $seoUrlPersister,
EntityRepositoryInterface $salesChannelRepository,
EntityRepository $salesChannelRepository,
SlugifyInterface $slugify
) {
$this->seoUrlPersister = $seoUrlPersister;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use Shopware\Core\Content\Sitemap\Provider\AbstractUrlProvider;
use Shopware\Core\Content\Sitemap\Struct\Url;
use Shopware\Core\Content\Sitemap\Struct\UrlResult;
use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\FetchModeHelper;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
Expand All @@ -57,23 +57,14 @@ class CustomUrlProvider extends AbstractUrlProvider
public const CHANGE_FREQ = 'daily';
public const PRIORITY = 1.0;

/**
* @var EntityRepositoryInterface
*/
private EntityRepositoryInterface $exampleRepository;
private EntityRepository $exampleRepository;

/**
* @var Connection
*/
private Connection $connection;

/**
* @var RouterInterface
*/
private RouterInterface $router;

public function __construct(
EntityRepositoryInterface $exampleRepository,
EntityRepository $exampleRepository,
Connection $connection,
RouterInterface $router
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ Now we can use the product repository in our subscriber.
namespace Swag\BasicExample\Subscriber;

use Shopware\Core\Content\Product\ProductEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;

class ProductSubscriber implements EventSubscriberInterface
{
private EntityRepositoryInterface $productRepository;
private EntityRepository $productRepository;

public function __construct(
EntityRepositoryInterface $productRepository
EntityRepository $productRepository
) {
$this->productRepository = $productRepository;
}
Expand All @@ -184,18 +184,18 @@ Let's have a look at the final implementation of the subscriber.
namespace Swag\BasicExample\Subscriber;

use Shopware\Core\Content\Product\ProductEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;

class ProductSubscriber implements EventSubscriberInterface
{
private EntityRepositoryInterface $productRepository;
private EntityRepository $productRepository;

public function __construct(
EntityRepositoryInterface $productRepository
EntityRepository $productRepository
) {
$this->productRepository = $productRepository;
}
Expand Down
15 changes: 3 additions & 12 deletions guides/plugins/plugins/framework/data-handling/add-data-indexer.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,23 @@ namespace Swag\BasicExample\Core\Framework\DataAbstractionLayer\Indexing;
use Doctrine\DBAL\Connection;
use Shopware\Core\Checkout\Customer\CustomerDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Dbal\Common\IteratorFactory;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexer;
use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexingMessage;
use Shopware\Core\Framework\Uuid\Uuid;

class ExampleIndexer extends EntityIndexer
{
/**
* @var IteratorFactory
*/
private IteratorFactory $iteratorFactory;

/**
* @var EntityRepositoryInterface
*/
private EntityRepositoryInterface $repository;
private EntityRepository $repository;

/**
* @var Connection
*/
private Connection $connection;

public function __construct(
IteratorFactory $iteratorFactory,
EntityRepositoryInterface $repository,
EntityRepository $repository,
Connection $connection
) {
$this->iteratorFactory = $iteratorFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ And here's the respective class including its constructor:

namespace Swag\BasicExample\Service;

use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;

class ReadingData
{
private EntityRepositoryInterface $productRepository;
private EntityRepository $productRepository;

public function __construct(EntityRepositoryInterface $productRepository)
public function __construct(EntityRepository $productRepository)
{
$this->productRepository = $productRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ And here's the respective class including its constructor:

namespace Swag\BasicExample\Service;

use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;

class WritingData
{
private EntityRepositoryInterface $productRepository;
private EntityRepository $productRepository;

private EntityRepositoryInterface $taxRepository;
private EntityRepository $taxRepository;

public function __construct(EntityRepositoryInterface $productRepository, EntityRepositoryInterface $taxRepository)
public function __construct(EntityRepository $productRepository, EntityRepository $taxRepository)
{
$this->productRepository = $productRepository;
$this->taxRepository = $taxRepository;
Expand Down
12 changes: 6 additions & 6 deletions guides/plugins/plugins/framework/flow/add-flow-builder-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ Our new class has to extend from the abstract class `Shopware\Core\Framework\Eve
namespace Swag\ExamplePlugin\Core\Content\Flow\Dispatching\Action;

use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Uuid\Uuid;
use Swag\ExamplePlugin\Core\Framework\Event\TagAware;
use Shopware\Core\Framework\Event\FlowEvent;

class CreateTagAction extends FlowAction
{
private EntityRepositoryInterface $tagRepository;
private EntityRepository $tagRepository;

public function __construct(EntityRepositoryInterface $tagRepository)
public function __construct(EntityRepository $tagRepository)
{
// you would need this repository to create a tag
$this->tagRepository = $tagRepository;
Expand Down Expand Up @@ -162,16 +162,16 @@ As you can see, several methods are already implemented:
namespace Swag\ExamplePlugin\Core\Content\Flow\Dispatching\Action;

use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Uuid\Uuid;
use Swag\ExamplePlugin\Core\Framework\Event\TagAware;
use Shopware\Core\Content\Flow\Dispatching\StorableFlow;

class CreateTagAction extends FlowAction
{
private EntityRepositoryInterface $tagRepository;
private EntityRepository $tagRepository;

public function __construct(EntityRepositoryInterface $tagRepository)
public function __construct(EntityRepository $tagRepository)
{
// you would need this repository to create a tag
$this->tagRepository = $tagRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Now we can create a new class `ExampleRoute` which uses our previously created `
namespace Swag\BasicExample\Core\Content\Example\SalesChannel;

use OpenApi\Annotations as OA;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\Framework\Routing\Annotation\Entity;
Expand All @@ -66,9 +66,9 @@ use Symfony\Component\Routing\Annotation\Route;
*/
class ExampleRoute extends AbstractExampleRoute
{
protected EntityRepositoryInterface $exampleRepository;
protected EntityRepository $exampleRepository;

public function __construct(EntityRepositoryInterface $exampleRepository)
public function __construct(EntityRepository $exampleRepository)
{
$this->exampleRepository = $exampleRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ First, we have to create a new class which extends `AbstractExampleRoute`. In th
namespace Swag\BasicExample\Core\Content\Example\SalesChannel;

use OpenApi\Annotations as OA;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Routing\Annotation\Entity;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
Expand All @@ -33,11 +33,11 @@ use Symfony\Component\Routing\Annotation\Route;
*/
class ExampleRouteDecorator extends AbstractExampleRoute
{
protected EntityRepositoryInterface $exampleRepository;
protected EntityRepository $exampleRepository;

private AbstractExampleRoute $decorated;

public function __construct(EntityRepositoryInterface $exampleRepository, AbstractExampleRoute $exampleRoute)
public function __construct(EntityRepository $exampleRepository, AbstractExampleRoute $exampleRoute)
{
$this->exampleRepository = $exampleRepository;
$this->decorated = $exampleRoute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Gateway\Local;

use Shopware\Core\Defaults;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\System\Currency\CurrencyEntity;
use SwagMigrationAssistant\Migration\EnvironmentInformation;
Expand All @@ -133,14 +133,14 @@ class ShopwareLocalGateway implements ShopwareGatewayInterface

private ConnectionFactoryInterface $connectionFactory;

private EntityRepositoryInterface $currencyRepository;
private EntityRepository $currencyRepository;

public function __construct(
ReaderRegistry $readerRegistry,
EnvironmentReaderInterface $localEnvironmentReader,
TableReaderInterface $localTableReader,
ConnectionFactoryInterface $connectionFactory,
EntityRepositoryInterface $currencyRepository
EntityRepository $currencyRepository
) {
$this->readerRegistry = $readerRegistry;
$this->localEnvironmentReader = $localEnvironmentReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace SwagMigrationExtendConverterExample\Profile\Shopware\Premapping;

use Shopware\Core\Content\Product\Aggregate\ProductManufacturer\ProductManufacturerEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting;
use SwagMigrationAssistant\Migration\Gateway\GatewayRegistryInterface;
Expand All @@ -40,7 +40,7 @@ class ManufacturerReader extends AbstractPremappingReader
{
private const MAPPING_NAME = 'swag_manufacturer';

private EntityRepositoryInterface $manufacturerRepo;
private EntityRepository $manufacturerRepo;

private GatewayRegistryInterface $gatewayRegistry;

Expand All @@ -49,7 +49,7 @@ class ManufacturerReader extends AbstractPremappingReader
private array $preselectionSourceNameDictionary;

public function __construct(
EntityRepositoryInterface $manufacturerRepo,
EntityRepository $manufacturerRepo,
GatewayRegistryInterface $gatewayRegistry
) {
$this->manufacturerRepo = $manufacturerRepo;
Expand Down