Adapter/ShopwareAdapter/ServiceBus/CommandHandler/Variation/RemoveVariationCommandHandler.php
public function handle(CommandInterface $command)
    {
        $identifier = $command->getPayload();

        $identity = $this->identityService->findOneBy([
            'objectIdentifier' => (string) $identifier,
            'objectType' => Variation::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $identity) {
            $this->logger->notice('no matching identity found', ['command' => $command]);

            return false;
        }

        $repository = $this->entityManager->getRepository(Detail::class);
        $variation = $repository->find($identity->getAdapterIdentifier());

        if (null !== $variation) {
            $this->entityManager->remove($variation);
            $this->entityManager->flush();
        } else {
            $this->logger->notice('identity removed but the object was not found', ['command' => $command]);
        }

        $identities = $this->identityService->findBy([
            'objectIdentifier' => $identifier,
        ]);

        array_walk($identities, function (Identity $identity) {
            $this->identityService->remove($identity);
        });

        return true;
    }
public function handle(CommandInterface $command)
    {
        $identifier = $command->getPayload();

        $identity = $this->identityService->findOneBy([
            'objectIdentifier' => (string) $identifier,
            'objectType' => Variation::TYPE,
            'adapterName' => ShopwareAdapter::NAME,
        ]);

        if (null === $identity) {
            $this->logger->notice('no matching identity found', ['command' => $command]);

            return false;
        }

        $repository = $this->entityManager->getRepository(Detail::class);
        $variation = $repository->find($identity->getAdapterIdentifier());

        if (null !== $variation) {
            $this->entityManager->remove($variation);
            $this->entityManager->flush();
        } else {
            $this->logger->notice('identity removed but the object was not found', ['command' => $command]);
        }

        $identities = $this->identityService->findBy([
            'objectIdentifier' => $identifier,
        ]);

        array_walk($identities, function (Identity $identity) {
            $this->identityService->remove($identity);
        });

        return true;
    }
{@inheritdoc}

@param TransferObjectCommand $command