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

        $this->bundleHelper->registerBundleModels();

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

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

            return false;
        }

        /**
         * @var EntityRepository $repository
         */
        $repository = $this->entityManager->getRepository(BundleModel::class);

        /**
         * @var BundleModel $bundleModel
         */
        $bundleModel = $repository->find($identity->getAdapterIdentifier());

        if (null === $bundleModel) {
            $this->logger->notice('identity removed but the object was not found', ['command' => $command]);

            return false;
        }

        $this->entityManager->remove($bundleModel);
        $this->entityManager->flush();

        $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();

        $this->bundleHelper->registerBundleModels();

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

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

            return false;
        }

        /**
         * @var EntityRepository $repository
         */
        $repository = $this->entityManager->getRepository(BundleModel::class);

        /**
         * @var BundleModel $bundleModel
         */
        $bundleModel = $repository->find($identity->getAdapterIdentifier());

        if (null === $bundleModel) {
            $this->logger->notice('identity removed but the object was not found', ['command' => $command]);

            return false;
        }

        $this->entityManager->remove($bundleModel);
        $this->entityManager->flush();

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

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

        return true;
    }
{@inheritdoc}

@param TransferObjectCommand $command