Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #36

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Entity/AbstractVacuumRelationHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
*/
Expand Down
4 changes: 2 additions & 2 deletions Entity/VacuumXMLRelationHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getTagName()
/**
* @param string $tagName
*
* @return VacuumXMlRelationHistory
* @return VacuumXMLRelationHistory
*/
public function setTagName(string $tagName)
{
Expand All @@ -56,7 +56,7 @@ public function getTagId()
/**
* @param int $tagId
*
* @return VacuumXMlRelationHistory
* @return VacuumXMLRelationHistory
*/
public function setTagId(int $tagId)
{
Expand Down
11 changes: 9 additions & 2 deletions Pipeline/WordPress/IOWordPressPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class IOWordPressPipeline
*/
private $XMLHistoryManager;

/**
* @var string
*/
private $userClass;

/**
* IOWordPressPipeline constructor.
*
Expand All @@ -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;
}

/**
Expand All @@ -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))
Expand Down
16 changes: 14 additions & 2 deletions Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class AuthorDataExtractorStages implements PersisterStageInterface
*/
private $entityManager;

/**
* @var string
*/
private $userClass;

/**
* AuthorDataExtractorStages constructor.
*
Expand All @@ -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
Expand All @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

@paulandrieux paulandrieux Jan 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Category changed to BlogCategory in the 2.2.29 release of victoire, it should be reflected in composer.json, requiring ^2.2.29.
(cf: Victoire/victoire@2.2.28...2.2.29)

use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface;
use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface;

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions Utils/History/XMLHistoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -38,15 +38,15 @@ public function reload()
{
unset($this->histories);
$this->histories = $this->entityManager
->getRepository('VictoireVacuumBundle:VacuumXMlRelationHistory')
->getRepository('VictoireVacuumBundle:VacuumXMLRelationHistory')
->findAll();
}

/**
* @param AbstractXMLEntity $source
* @param $vicClass
*
* @return mixed|null|VacuumXMlRelationHistory
* @return mixed|null|VacuumXMLRelationHistory
*/
public function searchHistory(AbstractXMLEntity $source, $vicClass)
{
Expand Down Expand Up @@ -77,6 +77,7 @@ public function getVicEntity(AbstractVacuumRelationHistory $history)
$history->getVicId(),
$history->getVicClass()
);

throw new XMLHistoryException($message);
}

Expand All @@ -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));
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ machine:
services:
- redis
php:
version: 7.0.4
version: 7.1.9

dependencies:
override:
Expand Down