WellCommerce\Bundle\LocaleBundle\Command\DeleteLocaleCommand::deleteLocaleData PHP Method

deleteLocaleData() protected method

Deletes the locale
protected deleteLocaleData ( $localeCode, Symfony\Component\Console\Output\OutputInterface $output )
$localeCode
$output Symfony\Component\Console\Output\OutputInterface
    protected function deleteLocaleData($localeCode, OutputInterface $output)
    {
        $entityManager = $this->doctrineHelper->getEntityManager();
        $metadata = $this->doctrineHelper->getAllMetadata();
        $locale = $this->localeRepository->findOneBy(['code' => $localeCode]);
        if (!$locale instanceof LocaleInterface) {
            throw new InvalidArgumentException(sprintf('Wrong locale code "%s" was given', $localeCode));
        }
        foreach ($metadata as $classMetadata) {
            $reflectionClass = $classMetadata->getReflectionClass();
            if ($reflectionClass->implementsInterface(\WellCommerce\Bundle\LocaleBundle\Entity\LocaleAwareInterface::class)) {
                $repository = $entityManager->getRepository($reflectionClass->getName());
                $this->deleteTranslatableEntities($repository, $locale, $output);
            }
        }
        $entityManager->remove($locale);
    }