public getAllMetadata ( ) : Doctrine\Common\Persistence\Mapping\ClassMetadata[] | ||
return | Doctrine\Common\Persistence\Mapping\ClassMetadata[] |
protected function getTranslatableRespositories() : Collection { $collection = new ArrayCollection(); $metadata = $this->doctrineHelper->getAllMetadata(); foreach ($metadata as $classMetadata) { $reflectionClass = $classMetadata->getReflectionClass(); if ($reflectionClass->implementsInterface(LocaleAwareInterface::class)) { $repository = $this->entityManager->getRepository($reflectionClass->getName()); $collection->add($repository); } } return $collection; }
/** * Deletes the locale * * @param $localeCode * @param OutputInterface $output */ 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); }