diff --git a/Entity/AbstractVacuumRelationHistory.php b/Entity/AbstractVacuumRelationHistory.php index 98afe35..f23341c 100644 --- a/Entity/AbstractVacuumRelationHistory.php +++ b/Entity/AbstractVacuumRelationHistory.php @@ -11,7 +11,7 @@ * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="type", type="string") * @ORM\DiscriminatorMap({ - * "xml" = "Victoire\DevTools\VacuumBundle\Entity\VacuumXMlRelationHistory" + * "xml" = "Victoire\DevTools\VacuumBundle\Entity\VacuumXMLRelationHistory" * }) * @ORM\Table("vic_vacuum_historic") */ diff --git a/Entity/VacuumXMLRelationHistory.php b/Entity/VacuumXMLRelationHistory.php index 87eaae4..7340093 100644 --- a/Entity/VacuumXMLRelationHistory.php +++ b/Entity/VacuumXMLRelationHistory.php @@ -36,7 +36,7 @@ public function getTagName() /** * @param string $tagName * - * @return VacuumXMlRelationHistory + * @return VacuumXMLRelationHistory */ public function setTagName(string $tagName) { @@ -56,7 +56,7 @@ public function getTagId() /** * @param int $tagId * - * @return VacuumXMlRelationHistory + * @return VacuumXMLRelationHistory */ public function setTagId(int $tagId) { diff --git a/Pipeline/WordPress/IOWordPressPipeline.php b/Pipeline/WordPress/IOWordPressPipeline.php index d44cc2f..2c5c158 100644 --- a/Pipeline/WordPress/IOWordPressPipeline.php +++ b/Pipeline/WordPress/IOWordPressPipeline.php @@ -62,6 +62,11 @@ class IOWordPressPipeline */ private $XMLHistoryManager; + /** + * @var string + */ + private $userClass; + /** * IOWordPressPipeline constructor. * @@ -72,13 +77,15 @@ public function __construct( $kernelRootDir, MediaFormater $mediaFormater, CurlsTools $curlsTools, - XMLHistoryManager $XMLHistoryManager + XMLHistoryManager $XMLHistoryManager, + $vicUserClassPath ) { $this->entityManager = $entityManager; $this->kernelRootDir = $kernelRootDir; $this->mediaFormater = $mediaFormater; $this->curlsTools = $curlsTools; $this->XMLHistoryManager = $XMLHistoryManager; + $this->userClass = $vicUserClassPath; } /** @@ -102,7 +109,7 @@ public function preparePipeline($commandParameter, OutputInterface $output, Ques $pipeline ->pipe(new BlogDataExtractorStages()) - ->pipe(new AuthorDataExtractorStages($this->entityManager)) + ->pipe((new AuthorDataExtractorStages($this->entityManager))->setUserClass($this->userClass)) ->pipe(new CategoryDataExtractorStages()) ->pipe(new TagDataExtractorStages()) ->pipe(new VicBlogGeneratorStages($this->entityManager)) diff --git a/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php b/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php index dd4551f..9c98384 100644 --- a/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php @@ -19,6 +19,11 @@ class AuthorDataExtractorStages implements PersisterStageInterface */ private $entityManager; + /** + * @var string + */ + private $userClass; + /** * AuthorDataExtractorStages constructor. * @@ -29,6 +34,13 @@ public function __construct(EntityManager $entityManager) $this->entityManager = $entityManager; } + public function setUserClass(string $userClass) + { + $this->userClass = $userClass; + + return $this; + } + /** * Look for every Author in the dump, inside current db. * If there is no match, it throw an error and ask for creation of author @@ -52,8 +64,8 @@ public function __invoke(CommandPayloadInterface $payload) foreach ($channel->author as $wpAuthor) { $email = $xmlDataFormater->formatString('author_email', $wpAuthor); - $authorByUsername = $this->entityManager->getRepository('AppBundle:User\User')->findOneBy(['username' => $email]); - $authorByEmail = $this->entityManager->getRepository('AppBundle:User\User')->findOneBy(['email' => $email]); + $authorByUsername = $this->entityManager->getRepository($this->userClass)->findOneBy(['username' => $email]); + $authorByEmail = $this->entityManager->getRepository($this->userClass)->findOneBy(['email' => $email]); if (empty($authorByUsername) && empty($authorByEmail)) { $row = [ diff --git a/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php b/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php index 289d354..bc0b4f9 100644 --- a/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php +++ b/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php @@ -3,7 +3,7 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Category; use Doctrine\ORM\EntityManager; -use Victoire\Bundle\BlogBundle\Entity\Category; +use Victoire\Bundle\BlogBundle\Entity\BlogCategory; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; @@ -44,10 +44,10 @@ public function __invoke(CommandPayloadInterface $payload) $history = $payload->getXMLHistoryManager()->searchHistory($plCategory, Category::class); if (null == $history) { - $category = new Category(); + $category = new BlogCategory(); $category->setTitle($plCategory->getCategoryName()); $category->setSlug($plCategory->getCategoryNiceName()); - $payload->getNewVicBlog()->addCategorie($category); + $payload->getNewVicBlog()->addCategory($category); $history = $payload->getXMLHistoryManager()->generateHistory($plCategory, $category); $payload->getXMLHistoryManager()->flushHistory($category, $history); $progress->advance(); diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 98d9353..708a031 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -19,6 +19,7 @@ services: - "@victoire.vacuum_bundle.media_formater.utils" - "@victoire.vacuum_bundle.curl_tools.utils" - "@victoire.vacuum_bundle.xml_history_manager.utils" + - "%victoire_core.user_class%" ############################ #### UTILS diff --git a/Utils/History/XMLHistoryManager.php b/Utils/History/XMLHistoryManager.php index 815aa83..c62d648 100644 --- a/Utils/History/XMLHistoryManager.php +++ b/Utils/History/XMLHistoryManager.php @@ -4,7 +4,7 @@ use Doctrine\ORM\EntityManager; use Victoire\DevTools\VacuumBundle\Entity\AbstractVacuumRelationHistory; -use Victoire\DevTools\VacuumBundle\Entity\VacuumXMlRelationHistory; +use Victoire\DevTools\VacuumBundle\Entity\VacuumXMLRelationHistory; use Victoire\DevTools\VacuumBundle\Entity\WordPress\AbstractXMLEntity; use Victoire\DevTools\VacuumBundle\Utils\History\Exception\XMLHistoryException; @@ -16,7 +16,7 @@ class XMLHistoryManager implements HistoryManagerInterface private $entityManager; /** - * @var array|\Victoire\DevTools\VacuumBundle\Entity\VacuumXMlRelationHistory[] + * @var array|\Victoire\DevTools\VacuumBundle\Entity\VacuumXMLRelationHistory[] */ private $histories; @@ -38,7 +38,7 @@ public function reload() { unset($this->histories); $this->histories = $this->entityManager - ->getRepository('VictoireVacuumBundle:VacuumXMlRelationHistory') + ->getRepository('VictoireVacuumBundle:VacuumXMLRelationHistory') ->findAll(); } @@ -46,7 +46,7 @@ public function reload() * @param AbstractXMLEntity $source * @param $vicClass * - * @return mixed|null|VacuumXMlRelationHistory + * @return mixed|null|VacuumXMLRelationHistory */ public function searchHistory(AbstractXMLEntity $source, $vicClass) { @@ -77,6 +77,7 @@ public function getVicEntity(AbstractVacuumRelationHistory $history) $history->getVicId(), $history->getVicClass() ); + throw new XMLHistoryException($message); } @@ -87,11 +88,11 @@ public function getVicEntity(AbstractVacuumRelationHistory $history) * @param AbstractXMLEntity $source * @param $refined * - * @return VacuumXMlRelationHistory + * @return VacuumXMLRelationHistory */ public function generateHistory(AbstractXMLEntity $source, $refined) { - $history = new VacuumXMlRelationHistory(); + $history = new VacuumXMLRelationHistory(); $history->setTagId($source->getId()); $history->setTagName($source->getXmlTag()); $history->setVicClass(get_class($refined)); @@ -104,9 +105,9 @@ public function generateHistory(AbstractXMLEntity $source, $refined) /** * @param $entity - * @param VacuumXMlRelationHistory $history + * @param VacuumXMLRelationHistory $history */ - public function flushHistory($entity, VacuumXMlRelationHistory $history) + public function flushHistory($entity, VacuumXMLRelationHistory $history) { $this->entityManager->persist($entity); $this->entityManager->flush(); diff --git a/circle.yml b/circle.yml index a8a6427..b4ead22 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,7 @@ machine: services: - redis php: - version: 7.0.4 + version: 7.1.9 dependencies: override: