From 63cae0f9b82512775d50aa80bd074c31d75d34d9 Mon Sep 17 00:00:00 2001 From: made Date: Fri, 7 Apr 2017 11:31:34 +0200 Subject: [PATCH] Apply style ci --- Command/BlogImportCommand.php | 41 ++++++------- .../VictoireVacuumExtension.php | 4 +- Entity/AbstractVacuumRelationHistory.php | 11 +++- Entity/VacuumXMLRelationHistory.php | 11 ++-- Entity/WordPress/AbstractXMLEntity.php | 9 ++- Entity/WordPress/Article.php | 43 ++++++++++++- Entity/WordPress/Author.php | 14 ++++- Entity/WordPress/Blog.php | 46 +++++++++++++- Entity/WordPress/Category.php | 10 ++- Entity/WordPress/SEO.php | 4 +- Entity/WordPress/Tag.php | 8 ++- Entity/WordPress/Term.php | 13 +++- Payload/CommandPayload.php | 43 ++++++++----- Payload/CommandPayloadInterface.php | 22 ++++--- Pipeline/FileStageInterface.php | 2 +- Pipeline/PersisterStageInterface.php | 2 +- Pipeline/PipelineInterface.php | 2 +- Pipeline/ProcessorInterface.php | 3 +- Pipeline/StageInterface.php | 3 +- Pipeline/WordPress/IOWordPressPipeline.php | 15 +++-- .../WordPress/Pipeline/WordPressPipeline.php | 21 ++++--- .../Processor/WordPressProcessor.php | 3 +- .../Article/ArticleDataExtractorStages.php | 34 +++++------ .../Article/VicArticleAttachmentStages.php | 16 ++--- .../Article/VicArticleContentStages.php | 32 +++++----- .../Article/VicArticleGeneratorStages.php | 15 +++-- .../Author/AuthorDataExtractorStages.php | 21 ++++--- .../Stages/Blog/BlogDataExtractorStages.php | 24 ++++---- .../Stages/Blog/VicBlogGeneratorStages.php | 25 ++++---- .../Category/CategoryDataExtractorStages.php | 17 +++--- .../Category/VicCategoryGeneratorStages.php | 15 +++-- Pipeline/WordPress/Stages/FinalStages.php | 14 ++--- .../Pages/VicArticlesBusinessPagesStages.php | 21 +++---- .../WordPress/Stages/SEO/VicSEOGenerator.php | 61 ++++++++++--------- .../Stages/Tag/TagDataExtractorStages.php | 17 +++--- .../Stages/Tag/VicTagGeneratorStages.php | 17 +++--- .../Template/VicArticleTemplateBuilder.php | 29 ++++----- Tests/Command/BlogImportCommandTest.php | 4 +- Utils/Curl/CurlsTools.php | 16 +++-- .../History/Exception/XMLHistoryException.php | 3 +- Utils/History/HistoryManagerInterface.php | 15 +++-- Utils/History/XMLHistoryManager.php | 19 +++--- Utils/Media/MediaFormater.php | 36 ++++++----- Utils/Xml/XmlDataFormater.php | 17 +++--- 44 files changed, 472 insertions(+), 326 deletions(-) diff --git a/Command/BlogImportCommand.php b/Command/BlogImportCommand.php index 7bf094d..eec7ca8 100644 --- a/Command/BlogImportCommand.php +++ b/Command/BlogImportCommand.php @@ -9,17 +9,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; -use Symfony\Component\DomCrawler\Crawler; -use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\Serializer\Encoder\XmlEncoder; -use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; -use Symfony\Component\Serializer\Serializer; -use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\IOWordPressPipeline; use Symfony\Component\Console\Question\Question; +use Symfony\Component\HttpFoundation\File\File; /** - * Class BlogImportCommand - * @package Victoire\VacuumBundle\Command + * Class BlogImportCommand. */ class BlogImportCommand extends ContainerAwareCommand { @@ -36,7 +30,7 @@ public function configure() new InputOption('article_template_layout', '-atl', InputOption::VALUE_OPTIONAL, 'article template layout designation'), new InputOption('article_template_parent_id', '-atpid', InputOption::VALUE_OPTIONAL, 'article template parent id'), new InputOption('article_template_id', '-ati', InputOption::VALUE_OPTIONAL, 'Id of an existing article template'), - new InputOption('article_template_first_slot', '-atfs', InputOption::VALUE_OPTIONAL, 'slot designation for root widget map in article template') + new InputOption('article_template_first_slot', '-atfs', InputOption::VALUE_OPTIONAL, 'slot designation for root widget map in article template'), ]) ->setDescription('Import blog form dump') ->setHelp(<<<'EOT' @@ -61,7 +55,7 @@ public function configure() } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) @@ -69,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $questionHelper = $this->getQuestionHelper(); $commandParameters = []; - $requiredParameter = ["blog_name", "dump", "article_template_first_slot"]; + $requiredParameter = ['blog_name', 'dump', 'article_template_first_slot']; foreach ($requiredParameter as $parameter) { if (null == $input->getOption($parameter)) { @@ -103,9 +97,9 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($input->isInteractive()) { - $message = ""; + $message = ''; foreach ($commandParameters as $key => $parameter) { - $message .= "".$key.": ".$parameter."\n"; + $message .= ''.$key.': '.$parameter."\n"; } //summary @@ -122,13 +116,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $question = new ConfirmationQuestion( $questionHelper->getQuestion( - 'do you wish to continue ?' - , 'yes', '?'), + 'do you wish to continue ?', 'yes', '?'), true ); if (!$questionHelper->ask($input, $output, $question)) { $output->writeln('Command aborted'); + return 1; } } @@ -138,7 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output */ protected function interact(InputInterface $input, OutputInterface $output) @@ -155,7 +149,7 @@ protected function interact(InputInterface $input, OutputInterface $output) // blog name $question = new Question($questionHelper->getQuestion('blog name', $input->getOption('blog_name'))); $question->setValidator(function ($answer) { - return self::validateBlogName($answer); + return self::validateBlogName($answer); }); $blogName = (string) $questionHelper->ask($input, $output, $question); @@ -164,7 +158,7 @@ protected function interact(InputInterface $input, OutputInterface $output) // blog template id $question = new Question($questionHelper->getQuestion('blog template id', $input->getOption('blog_template'))); $question->setValidator(function ($answer) { - return self::validateTemplateId($answer); + return self::validateTemplateId($answer); }); $blogTemplateId = (int) $questionHelper->ask($input, $output, $question); @@ -182,7 +176,7 @@ protected function interact(InputInterface $input, OutputInterface $output) // path to dump $question = new Question($questionHelper->getQuestion('path to dump', $input->getOption('dump'))); $question->setValidator(function ($answer) { - return self::validatePath($answer); + return self::validatePath($answer); }); $pathToDump = (string) $questionHelper->ask($input, $output, $question); @@ -209,7 +203,7 @@ protected function interact(InputInterface $input, OutputInterface $output) // ArticleTemplate parent_id $question = new Question($questionHelper->getQuestion('Article template parent id', $input->getOption('article_template_parent_id'))); $question->setValidator(function ($answer) { - return self::validateTemplateId($answer); + return self::validateTemplateId($answer); }); $articleTemplateParentId = (int) $questionHelper->ask($input, $output, $question); @@ -219,7 +213,6 @@ protected function interact(InputInterface $input, OutputInterface $output) $question = new Question($questionHelper->getQuestion('Article Template first slot', $input->getOption('article_template_first_slot'))); $articleTemplateFirstSlot = (string) $questionHelper->ask($input, $output, $question); $input->setOption('article_template_first_slot', $articleTemplateFirstSlot); - } else { // ArticleTemplate Id @@ -240,6 +233,7 @@ protected function interact(InputInterface $input, OutputInterface $output) /** * @param $id int + * * @return int */ private function validateView($id) @@ -278,7 +272,7 @@ private function validatePath($path) throw new RuntimeException(sprintf('Wrong path the file "%s" can\'t be found', $path)); } - if (mime_content_type($path) != "application/xml") { + if (mime_content_type($path) != 'application/xml') { throw new RuntimeException('Wrong file format. Format accepted "xml"'); } @@ -309,6 +303,7 @@ private function validateArticleTemplateId($id) /** * @param $name + * * @return ConfirmationQuestion */ private function validateLayout($name) @@ -347,4 +342,4 @@ protected function getQuestionHelper() return $questionHelper; } -} \ No newline at end of file +} diff --git a/DependencyInjection/VictoireVacuumExtension.php b/DependencyInjection/VictoireVacuumExtension.php index ce282de..92b2be2 100644 --- a/DependencyInjection/VictoireVacuumExtension.php +++ b/DependencyInjection/VictoireVacuumExtension.php @@ -2,10 +2,10 @@ namespace Victoire\DevTools\VacuumBundle\DependencyInjection; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * This is the class that loads and manages your bundle configuration. diff --git a/Entity/AbstractVacuumRelationHistory.php b/Entity/AbstractVacuumRelationHistory.php index cd15d07..98afe35 100644 --- a/Entity/AbstractVacuumRelationHistory.php +++ b/Entity/AbstractVacuumRelationHistory.php @@ -5,8 +5,7 @@ use Doctrine\ORM\Mapping as ORM; /** - * Class VacuumRelationHistoric - * @package Victoire\DevTools\VacuumBundle\Entity + * Class VacuumRelationHistoric. * * @ORM\Entity * @ORM\InheritanceType("SINGLE_TABLE") @@ -51,11 +50,13 @@ public function getId() /** * @param int $id + * * @return AbstractVacuumRelationHistory */ public function setId(int $id) { $this->id = $id; + return $this; } @@ -69,11 +70,13 @@ public function getVicClass() /** * @param string $vicClass + * * @return AbstractVacuumRelationHistory */ public function setVicClass(string $vicClass) { $this->vicClass = $vicClass; + return $this; } @@ -87,11 +90,13 @@ public function getVicId() /** * @param int $vicId + * * @return AbstractVacuumRelationHistory */ public function setVicId(int $vicId) { $this->vicId = $vicId; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/VacuumXMLRelationHistory.php b/Entity/VacuumXMLRelationHistory.php index 190aec2..87eaae4 100644 --- a/Entity/VacuumXMLRelationHistory.php +++ b/Entity/VacuumXMLRelationHistory.php @@ -5,12 +5,11 @@ use Doctrine\ORM\Mapping as ORM; /** - * Class VacuumRelationHistoric - * @package Victoire\DevTools\VacuumBundle\Entity + * Class VacuumRelationHistoric. * * @ORM\Entity */ -class VacuumXMlRelationHistory extends AbstractVacuumRelationHistory +class VacuumXMLRelationHistory extends AbstractVacuumRelationHistory { /** * @var string @@ -36,11 +35,13 @@ public function getTagName() /** * @param string $tagName + * * @return VacuumXMlRelationHistory */ public function setTagName(string $tagName) { $this->tagName = $tagName; + return $this; } @@ -54,11 +55,13 @@ public function getTagId() /** * @param int $tagId + * * @return VacuumXMlRelationHistory */ public function setTagId(int $tagId) { $this->tagId = $tagId; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/AbstractXMLEntity.php b/Entity/WordPress/AbstractXMLEntity.php index 7c36ce9..893acbd 100644 --- a/Entity/WordPress/AbstractXMLEntity.php +++ b/Entity/WordPress/AbstractXMLEntity.php @@ -3,8 +3,7 @@ namespace Victoire\DevTools\VacuumBundle\Entity\WordPress; /** - * Class XMLEntity - * @package Victoire\DevTools\VacuumBundle\Entity\WordPress + * Class XMLEntity. */ abstract class AbstractXMLEntity { @@ -28,11 +27,13 @@ public function getId() /** * @param int $id + * * @return AbstractXMLEntity */ public function setId(int $id) { $this->id = $id; + return $this; } @@ -46,11 +47,13 @@ public function getXmlTag() /** * @param string $xmlTag + * * @return AbstractXMLEntity */ public function setXmlTag(string $xmlTag) { $this->xmlTag = $xmlTag; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/Article.php b/Entity/WordPress/Article.php index 58e2080..01ff748 100644 --- a/Entity/WordPress/Article.php +++ b/Entity/WordPress/Article.php @@ -2,7 +2,6 @@ namespace Victoire\DevTools\VacuumBundle\Entity\WordPress; - class Article extends AbstractXMLEntity { private $title; @@ -53,11 +52,13 @@ public function getTitle() /** * @param mixed $title + * * @return Article */ public function setTitle($title) { $this->title = $title; + return $this; } @@ -71,11 +72,13 @@ public function getSlug() /** * @param mixed $slug + * * @return Article */ public function setSlug($slug) { $this->slug = $slug; + return $this; } @@ -89,11 +92,13 @@ public function getLink() /** * @param mixed $link + * * @return Article */ public function setLink($link) { $this->link = $link; + return $this; } @@ -107,11 +112,13 @@ public function getPubDate() /** * @param mixed $pubDate + * * @return Article */ public function setPubDate($pubDate) { $this->pubDate = $pubDate; + return $this; } @@ -125,11 +132,13 @@ public function getCreator() /** * @param mixed $creator + * * @return Article */ public function setCreator($creator) { $this->creator = $creator; + return $this; } @@ -143,11 +152,13 @@ public function getDescription() /** * @param mixed $description + * * @return Article */ public function setDescription($description) { $this->description = $description; + return $this; } @@ -161,11 +172,13 @@ public function getContent() /** * @param mixed $content + * * @return Article */ public function setContent($content) { $this->content = $content; + return $this; } @@ -179,11 +192,13 @@ public function getExcerpt() /** * @param mixed $excerpt + * * @return Article */ public function setExcerpt($excerpt) { $this->excerpt = $excerpt; + return $this; } @@ -197,11 +212,13 @@ public function getPostId() /** * @param mixed $postId + * * @return Article */ public function setPostId($postId) { $this->postId = $postId; + return $this; } @@ -215,11 +232,13 @@ public function getPostDate() /** * @param mixed $postDate + * * @return Article */ public function setPostDate($postDate) { $this->postDate = $postDate; + return $this; } @@ -233,11 +252,13 @@ public function getPostDateGmt() /** * @param mixed $postDateGmt + * * @return Article */ public function setPostDateGmt($postDateGmt) { $this->postDateGmt = $postDateGmt; + return $this; } @@ -251,11 +272,13 @@ public function getStatus() /** * @param mixed $status + * * @return Article */ public function setStatus($status) { $this->status = $status; + return $this; } @@ -269,11 +292,13 @@ public function getPostParent() /** * @param mixed $postParent + * * @return Article */ public function setPostParent($postParent) { $this->postParent = $postParent; + return $this; } @@ -287,11 +312,13 @@ public function getMenuOrder() /** * @param mixed $menuOrder + * * @return Article */ public function setMenuOrder($menuOrder) { $this->menuOrder = $menuOrder; + return $this; } @@ -305,11 +332,13 @@ public function getPostType() /** * @param mixed $postType + * * @return Article */ public function setPostType($postType) { $this->postType = $postType; + return $this; } @@ -323,11 +352,13 @@ public function getAttachmentUrl() /** * @param mixed $attachmentUrl + * * @return Article */ public function setAttachmentUrl($attachmentUrl) { $this->attachmentUrl = $attachmentUrl; + return $this; } @@ -341,11 +372,13 @@ public function getAttachment() /** * @param mixed $attachment + * * @return Article */ public function setAttachment($attachment) { $this->attachment = $attachment; + return $this; } @@ -359,11 +392,13 @@ public function getCategory() /** * @param mixed $category + * * @return Article */ public function setCategory($category) { $this->category = $category; + return $this; } @@ -377,21 +412,25 @@ public function getTags() /** * @param $tag + * * @return $this */ public function addTag($tag) { array_push($this->tags, $tag); + return $this; } /** * @param mixed $tags + * * @return Article */ public function setTags($tags) { $this->tags = $tags; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/Author.php b/Entity/WordPress/Author.php index 914aeb5..a660c9f 100644 --- a/Entity/WordPress/Author.php +++ b/Entity/WordPress/Author.php @@ -26,11 +26,13 @@ public function getWpAuthorId() /** * @param mixed $wpAuthorId + * * @return Author */ public function setWpAuthorId($wpAuthorId) { $this->wpAuthorId = $wpAuthorId; + return $this; } @@ -44,11 +46,13 @@ public function getAuthorLogin() /** * @param mixed $authorLogin + * * @return Author */ public function setAuthorLogin($authorLogin) { $this->authorLogin = $authorLogin; + return $this; } @@ -62,11 +66,13 @@ public function getAuthorEmail() /** * @param mixed $authorEmail + * * @return Author */ public function setAuthorEmail($authorEmail) { $this->authorEmail = $authorEmail; + return $this; } @@ -80,11 +86,13 @@ public function getAuthorDisplayName() /** * @param mixed $authorDisplayName + * * @return Author */ public function setAuthorDisplayName($authorDisplayName) { $this->authorDisplayName = $authorDisplayName; + return $this; } @@ -98,11 +106,13 @@ public function getAuthorFirstName() /** * @param mixed $authorFirstName + * * @return Author */ public function setAuthorFirstName($authorFirstName) { $this->authorFirstName = $authorFirstName; + return $this; } @@ -116,11 +126,13 @@ public function getAuthorLastName() /** * @param mixed $authorLastName + * * @return Author */ public function setAuthorLastName($authorLastName) { $this->authorLastName = $authorLastName; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/Blog.php b/Entity/WordPress/Blog.php index a5752a2..6105163 100644 --- a/Entity/WordPress/Blog.php +++ b/Entity/WordPress/Blog.php @@ -6,8 +6,7 @@ use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; /** - * Class Blog - * @package Victoire\DevTools\VacuumBundle\Entity\WordPress + * Class Blog. */ class Blog extends AbstractXMLEntity { @@ -101,11 +100,13 @@ public function getBlogFolder() /** * @param Folder $blogFolder + * * @return Blog */ public function setBlogFolder(Folder $blogFolder) { $this->blogFolder = $blogFolder; + return $this; } @@ -119,11 +120,13 @@ public function getContentWidgetMap() /** * @param WidgetMap $contentWidgetMap + * * @return Blog */ public function setContentWidgetMap(WidgetMap $contentWidgetMap) { $this->contentWidgetMap = $contentWidgetMap; + return $this; } @@ -137,11 +140,13 @@ public function getLocale() /** * @param string $locale + * * @return Blog */ public function setLocale(string $locale) { $this->locale = $locale; + return $this; } @@ -155,11 +160,13 @@ public function getTitle() /** * @param string $title + * * @return Blog */ public function setTitle(string $title) { $this->title = $title; + return $this; } @@ -173,11 +180,13 @@ public function getLink() /** * @param string $link + * * @return Blog */ public function setLink(string $link) { $this->link = $link; + return $this; } @@ -191,11 +200,13 @@ public function getDescription() /** * @param string $description + * * @return Blog */ public function setDescription(string $description) { $this->description = $description; + return $this; } @@ -209,11 +220,13 @@ public function getPublicationDate() /** * @param \DateTime $publicationDate + * * @return Blog */ public function setPublicationDate(\DateTime $publicationDate) { $this->publicationDate = $publicationDate; + return $this; } @@ -227,11 +240,13 @@ public function getBaseSiteUrl() /** * @param string $baseSiteUrl + * * @return Blog */ public function setBaseSiteUrl(string $baseSiteUrl) { $this->baseSiteUrl = $baseSiteUrl; + return $this; } @@ -245,11 +260,13 @@ public function getBaseBlogUrl() /** * @param string $baseBlogUrl + * * @return Blog */ public function setBaseBlogUrl(string $baseBlogUrl) { $this->baseBlogUrl = $baseBlogUrl; + return $this; } @@ -263,6 +280,7 @@ public function getAuthors() /** * @param $login + * * @return mixed */ public function getAuthor($username) @@ -276,21 +294,25 @@ public function getAuthor($username) /** * @param array $authors + * * @return Blog */ public function setAuthors(array $authors) { $this->authors = $authors; + return $this; } /** * @param $author + * * @return $this */ public function addAuthors($author) { array_push($this->authors, $author); + return $this; } @@ -304,21 +326,25 @@ public function getCategories() /** * @param array $categories + * * @return Blog */ public function setCategories(array $categories) { $this->categories = $categories; + return $this; } /** * @param $category + * * @return $this */ public function addCategory($category) { array_push($this->categories, $category); + return $this; } @@ -332,21 +358,25 @@ public function getTags() /** * @param array $tags + * * @return Blog */ public function setTags(array $tags) { $this->tags = $tags; + return $this; } /** * @param $tag + * * @return $this */ public function addTag($tag) { array_push($this->tags, $tag); + return $this; } @@ -360,11 +390,13 @@ public function getItems() /** * @param array $items + * * @return Blog */ public function setItems(array $items) { $this->items = $items; + return $this; } @@ -378,11 +410,13 @@ public function getTerms() /** * @param array $terms + * * @return Blog */ public function setTerms(array $terms) { $this->terms = $terms; + return $this; } @@ -396,11 +430,13 @@ public function getSeos() /** * @param array $seos + * * @return Blog */ public function setSeos(array $seos) { $this->seos = $seos; + return $this; } @@ -414,21 +450,25 @@ public function getArticles(): array /** * @param array $articles + * * @return Blog */ public function setArticles(array $articles): Blog { $this->articles = $articles; + return $this; } /** * @param $article + * * @return $this */ public function addArticle($article) { array_push($this->articles, $article); + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/Category.php b/Entity/WordPress/Category.php index 6edba07..5dfb53b 100644 --- a/Entity/WordPress/Category.php +++ b/Entity/WordPress/Category.php @@ -34,11 +34,13 @@ public function getTerm() /** * @param Term $term + * * @return Category */ public function setTerm($term) { $this->term = $term; + return $this; } @@ -52,11 +54,13 @@ public function getCategoryNicename() /** * @param mixed $categoryNicename + * * @return Category */ public function setCategoryNicename($categoryNicename) { $this->categoryNicename = $categoryNicename; + return $this; } @@ -70,11 +74,13 @@ public function getCategoryParent() /** * @param mixed $categoryParent + * * @return Category */ public function setCategoryParent($categoryParent) { $this->categoryParent = $categoryParent; + return $this; } @@ -88,11 +94,13 @@ public function getCategoryName() /** * @param mixed $categoryName + * * @return Category */ public function setCategoryName($categoryName) { $this->categoryName = $categoryName; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/SEO.php b/Entity/WordPress/SEO.php index b4dee28..0cffc82 100644 --- a/Entity/WordPress/SEO.php +++ b/Entity/WordPress/SEO.php @@ -11,6 +11,4 @@ class SEO private $noIndex; private $noFollow; - - -} \ No newline at end of file +} diff --git a/Entity/WordPress/Tag.php b/Entity/WordPress/Tag.php index 113bfb9..944d2ef 100644 --- a/Entity/WordPress/Tag.php +++ b/Entity/WordPress/Tag.php @@ -29,11 +29,13 @@ public function getTerm() /** * @param mixed $term + * * @return Tag */ public function setTerm($term) { $this->term = $term; + return $this; } @@ -47,11 +49,13 @@ public function getTagSlug() /** * @param mixed $tagSlug + * * @return Tag */ public function setTagSlug($tagSlug) { $this->tagSlug = $tagSlug; + return $this; } @@ -65,11 +69,13 @@ public function getTagName() /** * @param mixed $tagName + * * @return Tag */ public function setTagName($tagName) { $this->tagName = $tagName; + return $this; } -} \ No newline at end of file +} diff --git a/Entity/WordPress/Term.php b/Entity/WordPress/Term.php index daa7662..a520e3a 100644 --- a/Entity/WordPress/Term.php +++ b/Entity/WordPress/Term.php @@ -3,12 +3,11 @@ * Created by PhpStorm. * User: made * Date: 16/03/17 - * Time: 17:21 + * Time: 17:21. */ namespace Victoire\DevTools\VacuumBundle\Entity\WordPress; - class Term { private $termId; @@ -29,11 +28,13 @@ public function getTermId() /** * @param mixed $termId + * * @return Term */ public function setTermId($termId) { $this->termId = $termId; + return $this; } @@ -47,11 +48,13 @@ public function getTermTaxonomy() /** * @param mixed $termTaxonomy + * * @return Term */ public function setTermTaxonomy($termTaxonomy) { $this->termTaxonomy = $termTaxonomy; + return $this; } @@ -65,11 +68,13 @@ public function getTermSlug() /** * @param mixed $termSlug + * * @return Term */ public function setTermSlug($termSlug) { $this->termSlug = $termSlug; + return $this; } @@ -83,11 +88,13 @@ public function getParent() /** * @param mixed $parent + * * @return Term */ public function setParent($parent) { $this->parent = $parent; + return $this; } -} \ No newline at end of file +} diff --git a/Payload/CommandPayload.php b/Payload/CommandPayload.php index 535d3e9..cfca4f9 100644 --- a/Payload/CommandPayload.php +++ b/Payload/CommandPayload.php @@ -7,13 +7,10 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; use Victoire\Bundle\BlogBundle\Entity\Blog; -use Victoire\Bundle\MediaBundle\Entity\Folder; -use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; use Victoire\DevTools\VacuumBundle\Utils\History\XMLHistoryManager; /** - * Class WordPressPayload - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress + * Class WordPressPayload. */ class CommandPayload implements CommandPayloadInterface { @@ -54,8 +51,9 @@ class CommandPayload implements CommandPayloadInterface /** * WordPressPlayload constructor. - * @param array $parameters - * @param ProgressBar $progressBar + * + * @param array $parameters + * @param ProgressBar $progressBar * @param QuestionHelper $questionHelper */ public function __construct( @@ -64,8 +62,7 @@ public function __construct( QuestionHelper $questionHelper, \SimpleXMLElement $rawData, XMLHistoryManager $XMLHistoryManager - ) - { + ) { $this->parameters = $parameters; $this->questionHelper = $questionHelper; $this->output = $output; @@ -75,7 +72,7 @@ public function __construct( } /** - * Generate custom style for command dispatch + * Generate custom style for command dispatch. */ private function loadCustomStyle() { @@ -85,6 +82,7 @@ private function loadCustomStyle() /** * @param string $key + * * @return mixed */ public function getParameter($key) @@ -95,11 +93,13 @@ public function getParameter($key) /** * @param $key * @param $value + * * @return $this */ public function addParameter($key, $value) { $this->parameters[$key] = $value; + return $this; } @@ -113,11 +113,13 @@ public function getParameters(): array /** * @param array $parameters + * * @return CommandPayload */ public function setParameters(array $parameters) { $this->parameters = $parameters; + return $this; } @@ -131,11 +133,13 @@ public function getOutput() /** * @param OutputInterface $output + * * @return CommandPayload */ public function setOutput(OutputInterface $output) { $this->output = $output; + return $this; } @@ -149,11 +153,13 @@ public function getQuestionHelper() /** * @param QuestionHelper $questionHelper + * * @return CommandPayload */ public function setQuestionHelper(QuestionHelper $questionHelper) { $this->questionHelper = $questionHelper; + return $this; } @@ -167,11 +173,13 @@ public function getRawData() /** * @param \SimpleXMLElement $rawData + * * @return CommandPayload */ public function setRawData(\SimpleXMLElement $rawData) { $this->rawData = $rawData; + return $this; } @@ -185,11 +193,13 @@ public function getTmpBlog() /** * @param \Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog $tmpBlog + * * @return CommandPayload */ public function setTmpBlog(\Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog $tmpBlog) { $this->tmpBlog = $tmpBlog; + return $this; } @@ -203,11 +213,13 @@ public function getNewVicBlog() /** * @param Blog $newVicBlog + * * @return CommandPayload */ public function setNewVicBlog(Blog $newVicBlog) { $this->newVicBlog = $newVicBlog; + return $this; } @@ -221,16 +233,19 @@ public function getXMLHistoryManager() /** * @param XMLHistoryManager $XMLHistoryManager + * * @return CommandPayload */ public function setXMLHistoryManager(XMLHistoryManager $XMLHistoryManager) { $this->XMLHistoryManager = $XMLHistoryManager; + return $this; } /** * @param null $value + * * @return ProgressBar */ public function getNewProgressBar($value = null) @@ -247,7 +262,7 @@ public function getNewProgressBar($value = null) */ public function getNewStageTitleMessage($message) { - $this->output->writeln("".$message.""); + $this->output->writeln(''.$message.''); } /** @@ -255,12 +270,12 @@ public function getNewStageTitleMessage($message) */ public function getNewSuccessMessage($message) { - $this->output->writeln("".$message.""); + $this->output->writeln(''.$message.''); } public function jumpLine() { - $this->output->writeln(""); + $this->output->writeln(''); } /** @@ -268,7 +283,7 @@ public function jumpLine() */ public function throwErrorAndStop($message) { - $this->output->writeln("".$message.""); + $this->output->writeln(''.$message.''); exit(1); } -} \ No newline at end of file +} diff --git a/Payload/CommandPayloadInterface.php b/Payload/CommandPayloadInterface.php index 0ee83ac..ca5ac67 100644 --- a/Payload/CommandPayloadInterface.php +++ b/Payload/CommandPayloadInterface.php @@ -5,20 +5,19 @@ use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; -use Victoire\DevTools\VacuumBundle\Entity\VacuumXMlRelationHistory; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog; use Victoire\DevTools\VacuumBundle\Utils\History\XMLHistoryManager; /** - * Interface PayloadInterface - * @package Victoire\DevTools\VacuumBundle\Pipeline + * Interface PayloadInterface. */ interface CommandPayloadInterface { /** * WordPressPlayload constructor. - * @param array $parameters - * @param ProgressBar $progressBar + * + * @param array $parameters + * @param ProgressBar $progressBar * @param QuestionHelper $questionHelper */ public function __construct( @@ -36,6 +35,7 @@ public function getParameters(); /** * @param $key string + * * @return mixed */ public function getParameter($key); @@ -77,6 +77,7 @@ public function getTmpBlog(); /** * @param Blog $blog + * * @return mixed */ public function setTmpBlog(Blog $blog); @@ -88,6 +89,7 @@ public function getNewVicBlog(); /** * @param \Victoire\Bundle\BlogBundle\Entity\Blog $blog + * * @return mixed */ public function setNewVicBlog(\Victoire\Bundle\BlogBundle\Entity\Blog $blog); @@ -99,31 +101,35 @@ public function getXMLHistoryManager(); /** * @param XMLHistoryManager $XMLHistoryManager + * * @return CommandPayload */ public function setXMLHistoryManager(XMLHistoryManager $XMLHistoryManager); - /** * @param null $value + * * @return mixed */ public function getNewProgressBar($value = null); /** * @param $message + * * @return mixed */ public function getNewSuccessMessage($message); /** * @param $message + * * @return mixed */ public function throwErrorAndStop($message); /** * @param $message + * * @return mixed */ public function getNewStageTitleMessage($message); @@ -132,6 +138,4 @@ public function getNewStageTitleMessage($message); * @return mixed */ public function jumpLine(); - - -} \ No newline at end of file +} diff --git a/Pipeline/FileStageInterface.php b/Pipeline/FileStageInterface.php index 30537ef..1c695fb 100644 --- a/Pipeline/FileStageInterface.php +++ b/Pipeline/FileStageInterface.php @@ -5,4 +5,4 @@ interface FileStageInterface extends StageInterface { public function __construct($kernerRootDir); -} \ No newline at end of file +} diff --git a/Pipeline/PersisterStageInterface.php b/Pipeline/PersisterStageInterface.php index 651747d..700949f 100644 --- a/Pipeline/PersisterStageInterface.php +++ b/Pipeline/PersisterStageInterface.php @@ -7,4 +7,4 @@ interface PersisterStageInterface extends StageInterface { public function __construct(EntityManager $entityManager); -} \ No newline at end of file +} diff --git a/Pipeline/PipelineInterface.php b/Pipeline/PipelineInterface.php index fa6c1ce..cdc40c4 100644 --- a/Pipeline/PipelineInterface.php +++ b/Pipeline/PipelineInterface.php @@ -12,4 +12,4 @@ interface PipelineInterface extends StageInterface * @return static */ public function pipe(callable $operation); -} \ No newline at end of file +} diff --git a/Pipeline/ProcessorInterface.php b/Pipeline/ProcessorInterface.php index eccd2ae..d522144 100644 --- a/Pipeline/ProcessorInterface.php +++ b/Pipeline/ProcessorInterface.php @@ -7,7 +7,8 @@ interface ProcessorInterface /** * @param array $stages * @param $payload + * * @return mixed */ public function process(array $stages, $payload); -} \ No newline at end of file +} diff --git a/Pipeline/StageInterface.php b/Pipeline/StageInterface.php index 802037e..eb856f6 100644 --- a/Pipeline/StageInterface.php +++ b/Pipeline/StageInterface.php @@ -8,7 +8,8 @@ interface StageInterface { /** * @param CommandPayloadInterface $payload + * * @return $payload */ public function __invoke(CommandPayloadInterface $payload); -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/IOWordPressPipeline.php b/Pipeline/WordPress/IOWordPressPipeline.php index 6f878af..d44cc2f 100644 --- a/Pipeline/WordPress/IOWordPressPipeline.php +++ b/Pipeline/WordPress/IOWordPressPipeline.php @@ -5,6 +5,7 @@ use Doctrine\ORM\EntityManager; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; +use Victoire\DevTools\VacuumBundle\Payload\CommandPayload; use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Pipeline\WordPressPipeline; use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Processor\WordPressProcessor; use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article\ArticleDataExtractorStages; @@ -22,14 +23,12 @@ use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Tag\TagDataExtractorStages; use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Tag\VicTagGeneratorStages; use Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Template\VicArticleTemplateBuilder; -use Victoire\DevTools\VacuumBundle\Payload\CommandPayload; use Victoire\DevTools\VacuumBundle\Utils\Curl\CurlsTools; use Victoire\DevTools\VacuumBundle\Utils\History\XMLHistoryManager; use Victoire\DevTools\VacuumBundle\Utils\Media\MediaFormater; /** - * Class IOWordPressPipeline - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress + * Class IOWordPressPipeline. */ class IOWordPressPipeline { @@ -51,7 +50,7 @@ class IOWordPressPipeline /** * @var MediaFormater */ - private $mediaFormater; + private $mediaFormater; /** * @var CurlsTools @@ -65,6 +64,7 @@ class IOWordPressPipeline /** * IOWordPressPipeline constructor. + * * @param $data */ public function __construct( @@ -73,8 +73,7 @@ public function __construct( MediaFormater $mediaFormater, CurlsTools $curlsTools, XMLHistoryManager $XMLHistoryManager - ) - { + ) { $this->entityManager = $entityManager; $this->kernelRootDir = $kernelRootDir; $this->mediaFormater = $mediaFormater; @@ -88,7 +87,7 @@ public function __construct( public function preparePipeline($commandParameter, OutputInterface $output, QuestionHelper $questionHelper) { $raw = file_get_contents($commandParameter['dump']); - $raw = str_replace(["wp:","dc:",":encoded"],"",$raw); + $raw = str_replace(['wp:', 'dc:', ':encoded'], '', $raw); $rawData = simplexml_load_string($raw); $payload = new CommandPayload( @@ -128,4 +127,4 @@ public function getOutput() { return $this->output; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Pipeline/WordPressPipeline.php b/Pipeline/WordPress/Pipeline/WordPressPipeline.php index c74df45..506549a 100644 --- a/Pipeline/WordPress/Pipeline/WordPressPipeline.php +++ b/Pipeline/WordPress/Pipeline/WordPressPipeline.php @@ -2,14 +2,12 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Pipeline; +use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; use Victoire\DevTools\VacuumBundle\Pipeline\PipelineInterface; use Victoire\DevTools\VacuumBundle\Pipeline\ProcessorInterface; -use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; - /** - * Class WordPressPipeline - * @package Victoire\DevTools\VacuumBundle\Pipeline\Pipeline + * Class WordPressPipeline. */ class WordPressPipeline implements PipelineInterface { @@ -25,14 +23,14 @@ class WordPressPipeline implements PipelineInterface /** * WordPressPipeline constructor. - * @param array $stages + * + * @param array $stages * @param ProcessorInterface|null $processor */ public function __construct( array $stages = [], ProcessorInterface $processor = null - ) - { + ) { foreach ($stages as $stage) { if (false === is_callable($stage)) { throw new \InvalidArgumentException('All stage should be callable'); @@ -45,29 +43,34 @@ public function __construct( /** * @param callable $operation + * * @return WordPressPipeline */ public function pipe(callable $operation) { $pipeline = clone $this; $pipeline->stages[] = $operation; + return $pipeline; } /** * @param $payload + * * @return mixed */ - public function process($payload) { + public function process($payload) + { return $this->processor->process($this->stages, $payload); } /** * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) { return $this->process($payload); } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Processor/WordPressProcessor.php b/Pipeline/WordPress/Processor/WordPressProcessor.php index 41cea47..a56c610 100644 --- a/Pipeline/WordPress/Processor/WordPressProcessor.php +++ b/Pipeline/WordPress/Processor/WordPressProcessor.php @@ -9,6 +9,7 @@ class WordPressProcessor implements ProcessorInterface /** * @param array $stages * @param $payload + * * @return mixed */ public function process(array $stages, $payload) @@ -19,4 +20,4 @@ public function process(array $stages, $payload) return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php b/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php index f2982cb..c599b4b 100644 --- a/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Article/ArticleDataExtractorStages.php @@ -2,21 +2,19 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article; -use Gedmo\Tree\Mapping\Driver\Xml; -use Victoire\Bundle\SeoBundle\Entity\PageSeo; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Article; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Xml\XmlDataFormater; /** - * Class ArticleDataExtractorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article + * Class ArticleDataExtractorStages. */ class ArticleDataExtractorStages implements StageInterface { /** * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -30,18 +28,17 @@ public function __invoke(CommandPayloadInterface $payload) foreach ($channel->item as $wpArticle) { $postType = $xmlDataFormater->formatString('post_type', $wpArticle); - if ($postType == "post") { + if ($postType == 'post') { array_push($typePost, $wpArticle); - } elseif ($postType == "attachment") { + } elseif ($postType == 'attachment') { array_push($typeAttachement, $wpArticle); } } $progress = $payload->getNewProgressBar(count($typePost)); - $payload->getNewStageTitleMessage("Article Data extraction:"); + $payload->getNewStageTitleMessage('Article Data extraction:'); foreach ($typePost as $wpArticle) { - $article = new Article(); $article = self::hydrateArticle($article, $wpArticle, $payload, $xmlDataFormater); @@ -53,10 +50,11 @@ public function __invoke(CommandPayloadInterface $payload) } $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); unset($xmlDataFormater); + return $payload; } @@ -64,12 +62,13 @@ public function __invoke(CommandPayloadInterface $payload) * @param $article * @param $wpArticle * @param $payload + * * @return mixed */ private function hydrateArticle(Article $article, $wpArticle, CommandPayloadInterface $payload, XmlDataFormater $xmlDataFormater) { $article->setId($xmlDataFormater->formatInteger('post_id', $wpArticle)); - $article->setXmlTag("article"); + $article->setXmlTag('article'); $article->setTitle($xmlDataFormater->formatString('title', $wpArticle)); $article->setSlug($xmlDataFormater->formatString('post_name', $wpArticle)); $article->setLink($xmlDataFormater->formatString('link', $wpArticle)); @@ -95,6 +94,7 @@ private function hydrateArticle(Article $article, $wpArticle, CommandPayloadInte * @param $article * @param array $typeAttachement * @param $xmlDataFormater + * * @return mixed */ private function manageArticleAttachment($article, array $typeAttachement, $xmlDataFormater) @@ -103,7 +103,7 @@ private function manageArticleAttachment($article, array $typeAttachement, $xml foreach ($attachment->postmeta as $postMeta) { $value = $postMeta->meta_value; // should be update for multiple word press widget - if ($xmlDataFormater->formatString(0, $value) == "grande-image") { + if ($xmlDataFormater->formatString(0, $value) == 'grande-image') { if ($article->getPostId() == $xmlDataFormater->formatInteger('post_parent', $attachment)) { $article->setAttachmentUrl($xmlDataFormater->formatString('attachment_url', $attachment)); } @@ -124,20 +124,20 @@ private function setCategoryAndTag(Article $article, $wpArticle, XmlDataFormater { foreach ($wpArticle->category as $cat) { foreach ($cat->attributes() as $key => $attribute) { - if ($key == "domain") { + if ($key == 'domain') { $domain = $attribute; - } elseif ($key == "nicename") { + } elseif ($key == 'nicename') { $nicename = $xmlDataFormater->formatString(0, $attribute); } } - if ($domain == "post_tag") { + if ($domain == 'post_tag') { foreach ($payload->getNewVicBlog()->getTags() as $tag) { if ($tag->getSlug() == $nicename) { $article->addTag($tag); } } - } elseif ($domain == "category") { + } elseif ($domain == 'category') { foreach ($payload->getNewVicBlog()->getCategories() as $category) { if ($category->getSlug() == $nicename) { $article->setCategory($category); @@ -148,4 +148,4 @@ private function setCategoryAndTag(Article $article, $wpArticle, XmlDataFormater return $article; } } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStages.php b/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStages.php index 412d9bc..2381c56 100644 --- a/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStages.php +++ b/Pipeline/WordPress/Stages/Article/VicArticleAttachmentStages.php @@ -4,14 +4,12 @@ use Victoire\Bundle\BlogBundle\Entity\Article; use Victoire\Bundle\MediaBundle\Entity\Media; -use Victoire\DevTools\VacuumBundle\Pipeline\FileStageInterface; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Media\MediaFormater; /** - * Class VicArticleMediaBuilderStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article + * Class VicArticleMediaBuilderStages. */ class VicArticleAttachmentStages implements StageInterface { @@ -22,12 +20,12 @@ class VicArticleAttachmentStages implements StageInterface /** * VicArticleAttachmentStages constructor. + * * @param MediaFormater $mediaFormater */ public function __construct( MediaFormater $mediaFormater - ) - { + ) { $this->mediaFormater = $mediaFormater; } @@ -36,6 +34,7 @@ public function __construct( * article attachment url. * * @param CommandPayloadInterface $payload + * * @return CommandPayloadInterface */ public function __invoke(CommandPayloadInterface $payload) @@ -59,7 +58,8 @@ public function __invoke(CommandPayloadInterface $payload) } $payload->jumpLine(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php b/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php index a5b6882..8a78fdd 100644 --- a/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php +++ b/Pipeline/WordPress/Stages/Article/VicArticleContentStages.php @@ -2,11 +2,9 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article; -use Behat\Mink\Exception\Exception; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Article; -use Victoire\DevTools\VacuumBundle\Pipeline\FileStageInterface; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Curl\CurlsTools; use Victoire\DevTools\VacuumBundle\Utils\Media\MediaFormater; @@ -19,12 +17,12 @@ class VicArticleContentStages implements StageInterface /** * VicArticleContentStages constructor. + * * @param CurlsTools $curlsTools */ public function __construct( MediaFormater $mediaFormater - ) - { + ) { $this->mediaFormater = $mediaFormater; } @@ -33,6 +31,7 @@ public function __construct( * picture found in it and update link accordingly. * * @param CommandPayloadInterface $payload + * * @return CommandPayloadInterface */ public function __invoke(CommandPayloadInterface $payload) @@ -41,12 +40,10 @@ public function __invoke(CommandPayloadInterface $payload) $payload->getNewStageTitleMessage('Victoire Article Content generation:'); foreach ($payload->getTmpBlog()->getArticles() as $plArticle) { - $history = $payload->getXMLHistoryManager()->searchHistory($plArticle, \Victoire\Bundle\BlogBundle\Entity\Article::class); if (null == $history) { if (null != $plArticle->getContent()) { - $content = $plArticle->getContent(); $document = self::generateDOMDocument($content); @@ -64,17 +61,20 @@ public function __invoke(CommandPayloadInterface $payload) } $payload->jumpLine(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); + return $payload; } /** - * convert content in DOMDocument + * convert content in DOMDocument. * * @param $content + * * @return bool|\DOMDocument */ - private function generateDOMDocument($content) { + private function generateDOMDocument($content) + { $document = new \DOMDocument(); try { $document->loadHTML( @@ -92,15 +92,15 @@ private function generateDOMDocument($content) { /** * @param \DOMDocument $document + * * @return bool */ - private function handleImg(\DOMDocument $document, Article $article, $payload) { - - if (null != $document->getElementsByTagName("img")) { + private function handleImg(\DOMDocument $document, Article $article, $payload) + { + if (null != $document->getElementsByTagName('img')) { $xpath = new \DOMXPath($document); - $nodes = $xpath->query("//a//img"); + $nodes = $xpath->query('//a//img'); foreach ($nodes as $node) { - $distantPath = $this->mediaFormater->cleanUrl($node->getAttribute('src')); if (null != $article->getAttachment()) { @@ -117,4 +117,4 @@ private function handleImg(\DOMDocument $document, Article $article, $payload) { return $document; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStages.php b/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStages.php index 329e889..410e3d7 100644 --- a/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStages.php +++ b/Pipeline/WordPress/Stages/Article/VicArticleGeneratorStages.php @@ -4,14 +4,12 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BlogBundle\Entity\Article; -use Victoire\Bundle\MediaBundle\Entity\Media; use Victoire\Bundle\PageBundle\Entity\PageStatus; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; /** - * Class VicArticleGeneratorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Article + * Class VicArticleGeneratorStages. */ class VicArticleGeneratorStages implements PersisterStageInterface { @@ -22,6 +20,7 @@ class VicArticleGeneratorStages implements PersisterStageInterface /** * VicArticleGeneratorStages constructor. + * * @param EntityManager $entityManager */ public function __construct(EntityManager $entityManager) @@ -31,6 +30,7 @@ public function __construct(EntityManager $entityManager) /** * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -41,7 +41,6 @@ public function __invoke(CommandPayloadInterface $payload) $payload->getNewStageTitleMessage('Victoire Article generation:'); foreach ($payload->getTmpBlog()->getArticles() as $plArticle) { - $history = $payload->getXMLHistoryManager()->searchHistory($plArticle, Article::class); if (null == $history) { @@ -55,7 +54,7 @@ public function __invoke(CommandPayloadInterface $payload) } $article->setPublishedAt($plArticle->getPubDate()); - if ($plArticle->getStatus() == "publish") { + if ($plArticle->getStatus() == 'publish') { $article->setStatus(PageStatus::PUBLISHED); } if (null != $plArticle->getAttachment()) { @@ -89,9 +88,9 @@ public function __invoke(CommandPayloadInterface $payload) } } - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php b/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php index af5976c..dd4551f 100644 --- a/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Author/AuthorDataExtractorStages.php @@ -1,17 +1,16 @@ getRawData()->channel; $progress = $payload->getNewProgressBar(count($channel->author)); - $payload->getNewStageTitleMessage("Author data extraction:"); + $payload->getNewStageTitleMessage('Author data extraction:'); $missingAuthor = []; @@ -52,17 +53,16 @@ public function __invoke(CommandPayloadInterface $payload) $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]); + $authorByEmail = $this->entityManager->getRepository('AppBundle:User\User')->findOneBy(['email' => $email]); if (empty($authorByUsername) && empty($authorByEmail)) { - $row = [ $xmlDataFormater->formatInteger('author_id', $wpAuthor), $xmlDataFormater->formatString('author_login', $wpAuthor), $xmlDataFormater->formatString('author_email', $wpAuthor), $xmlDataFormater->formatString('author_display_name', $wpAuthor), $xmlDataFormater->formatString('author_first_name', $wpAuthor), - $xmlDataFormater->formatString('author_last_name', $wpAuthor) + $xmlDataFormater->formatString('author_last_name', $wpAuthor), ]; array_push($missingAuthor, $row); } else { @@ -87,10 +87,11 @@ public function __invoke(CommandPayloadInterface $payload) } $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); unset($xmlDataFormater); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStages.php b/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStages.php index d797423..e1890ae 100644 --- a/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Blog/BlogDataExtractorStages.php @@ -3,21 +3,21 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Blog; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Blog; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Xml\XmlDataFormater; /** - * Class BlogDataExtractorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Blog + * Class BlogDataExtractorStages. */ class BlogDataExtractorStages implements StageInterface { /** * Will extract the blog from raw data - * stop the command if more than one blog is in the dump + * stop the command if more than one blog is in the dump. * * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -25,24 +25,23 @@ public function __invoke(CommandPayloadInterface $payload) $xmlDataFormater = new XmlDataFormater(); $progress = $payload->getNewProgressBar(count($payload->getRawData()->channel)); - $payload->getNewStageTitleMessage("Blog data extraction:"); + $payload->getNewStageTitleMessage('Blog data extraction:'); if (count($payload->getRawData()->channel) > 1) { - $payload->throwErrorAndStop("Dump has more than on blog in it."); + $payload->throwErrorAndStop('Dump has more than on blog in it.'); } else { - $channel = $payload->getRawData()->channel; $blog = new Blog(); $blog->setId(1); - $blog->setXmlTag("channel"); + $blog->setXmlTag('channel'); $blog->setTitle($payload->getParameters()['blog_name']); $blog->setLink($xmlDataFormater->formatString('link', $channel)); $blog->setPublicationDate($xmlDataFormater->formatDate('pubDate', $channel)); $blog->setDescription($xmlDataFormater->formatString('description', $channel)); - $locale = $xmlDataFormater->formatString("language", $channel); - $locale = explode("-", $locale); + $locale = $xmlDataFormater->formatString('language', $channel); + $locale = explode('-', $locale); $blog->setLocale($locale[0]); $blog->setBaseSiteUrl($xmlDataFormater->formatString('base_site_url', $channel)); @@ -52,10 +51,11 @@ public function __invoke(CommandPayloadInterface $payload) } $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); unset($xmlDataFormater); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStages.php b/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStages.php index deec9a9..9f11393 100644 --- a/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStages.php +++ b/Pipeline/WordPress/Stages/Blog/VicBlogGeneratorStages.php @@ -4,13 +4,11 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BlogBundle\Entity\Blog; -use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; /** - * Class VicBlogGeneratorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Blog + * Class VicBlogGeneratorStages. */ class VicBlogGeneratorStages implements PersisterStageInterface { @@ -21,32 +19,36 @@ class VicBlogGeneratorStages implements PersisterStageInterface /** * VicBlogGeneratorStages constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } /** * @param $id + * * @return null|object|\Victoire\Bundle\TemplateBundle\Entity\Template */ private function getBaseTemplate($id) { $template = $this->entityManager->getRepository('VictoireTemplateBundle:Template')->find($id); + return $template; } /** * @param $id + * * @return null|object|\Victoire\Bundle\PageBundle\Entity\Page */ private function getParentPage($id) { $page = $this->entityManager->getRepository('VictoirePageBundle:Page')->find($id); + return $page; } @@ -55,6 +57,7 @@ private function getParentPage($id) * from tmpBlog, then persist it. * * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -65,10 +68,10 @@ public function __invoke(CommandPayloadInterface $payload) $history = $payload->getXMLHistoryManager()->searchHistory($payload->getTmpBlog(), Blog::class); if (null != $history) { - $payload->getNewStageTitleMessage("Victoire Blog update:"); + $payload->getNewStageTitleMessage('Victoire Blog update:'); $blog = $payload->getXMLHistoryManager()->getVicEntity($history); } else { - $payload->getNewStageTitleMessage("Victoire Blog generation:"); + $payload->getNewStageTitleMessage('Victoire Blog generation:'); $blog = new Blog(); $blog->setDefaultLocale($payload->getTmpBlog()->getLocale()); $blog->setCurrentLocale($blog->getDefaultLocale()); @@ -77,7 +80,7 @@ public function __invoke(CommandPayloadInterface $payload) $blog->setParent(self::getParentPage($parameters['blog_parent_id'])); $blog->setPublishedAt($payload->getTmpBlog()->getPublicationDate()); $blog->setCreatedAt($payload->getTmpBlog()->getPublicationDate()); - $history = $payload->getXMLHistoryManager()->generateHistory($payload->getTmpBlog(),$blog); + $history = $payload->getXMLHistoryManager()->generateHistory($payload->getTmpBlog(), $blog); foreach ($blog->getTranslations() as $key => $translation) { if ($key != $blog->getDefaultLocale()) { @@ -90,9 +93,9 @@ public function __invoke(CommandPayloadInterface $payload) $payload->setNewVicBlog($blog); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStages.php b/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStages.php index c208a0f..4143713 100644 --- a/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Category/CategoryDataExtractorStages.php @@ -3,20 +3,20 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Category; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Category; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Xml\XmlDataFormater; /** - * Class CategoryDataExtractorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Category + * Class CategoryDataExtractorStages. */ class CategoryDataExtractorStages implements StageInterface { /** - * Extract and add category from raw Data to tmpBlog + * Extract and add category from raw Data to tmpBlog. * * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -26,12 +26,12 @@ public function __invoke(CommandPayloadInterface $payload) $channel = $payload->getRawData()->channel; $progress = $payload->getNewProgressBar(count($channel->category)); - $payload->getNewStageTitleMessage("Category data extraction:"); + $payload->getNewStageTitleMessage('Category data extraction:'); foreach ($channel->category as $wpCategory) { $category = new Category(); $category->setId($xmlDataFormater->formatInteger('term_id', $wpCategory)); - $category->setXmlTag("category"); + $category->setXmlTag('category'); $category->setCategoryName($xmlDataFormater->formatString('cat_name', $wpCategory)); $category->setCategoryNicename($xmlDataFormater->formatString('category_nicename', $wpCategory)); $category->setCategoryParent($xmlDataFormater->formatInteger('category_parent', $wpCategory)); @@ -41,10 +41,11 @@ public function __invoke(CommandPayloadInterface $payload) } $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); unset($xmlDataFormater); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php b/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php index b1027bb..289d354 100644 --- a/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php +++ b/Pipeline/WordPress/Stages/Category/VicCategoryGeneratorStages.php @@ -4,12 +4,11 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BlogBundle\Entity\Category; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; /** - * Class VicCategoryGeneratorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Category + * Class VicCategoryGeneratorStages. */ class VicCategoryGeneratorStages implements PersisterStageInterface { @@ -20,17 +19,18 @@ class VicCategoryGeneratorStages implements PersisterStageInterface /** * CategoryGeneratorStages constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } /** * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -40,7 +40,6 @@ public function __invoke(CommandPayloadInterface $payload) $payload->getNewStageTitleMessage('Victoire Category generation:'); foreach ($payload->getTmpBlog()->getCategories() as $plCategory) { - $payload->getXMLHistoryManager()->reload(); $history = $payload->getXMLHistoryManager()->searchHistory($plCategory, Category::class); @@ -55,9 +54,9 @@ public function __invoke(CommandPayloadInterface $payload) } } - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/FinalStages.php b/Pipeline/WordPress/Stages/FinalStages.php index 686e08a..e5d13aa 100644 --- a/Pipeline/WordPress/Stages/FinalStages.php +++ b/Pipeline/WordPress/Stages/FinalStages.php @@ -3,12 +3,11 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages; use Doctrine\ORM\EntityManager; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; /** - * Class FinalStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages + * Class FinalStages. */ class FinalStages implements PersisterStageInterface { @@ -19,12 +18,12 @@ class FinalStages implements PersisterStageInterface /** * FinalStages constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } @@ -38,8 +37,9 @@ public function __invoke(CommandPayloadInterface $payload) $this->entityManager->persist($payload->getNewVicBlog()); $this->entityManager->flush(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Pages/VicArticlesBusinessPagesStages.php b/Pipeline/WordPress/Stages/Pages/VicArticlesBusinessPagesStages.php index ea16962..b41873c 100644 --- a/Pipeline/WordPress/Stages/Pages/VicArticlesBusinessPagesStages.php +++ b/Pipeline/WordPress/Stages/Pages/VicArticlesBusinessPagesStages.php @@ -4,15 +4,14 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage; +use Victoire\Bundle\CoreBundle\Entity\EntityProxy; use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\Widget\CKEditorBundle\Entity\WidgetCKEditor; -use Victoire\Bundle\CoreBundle\Entity\EntityProxy; /** - * Class VicArticlesBusinessPagesStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Pages + * Class VicArticlesBusinessPagesStages. */ class VicArticlesBusinessPagesStages implements PersisterStageInterface { @@ -23,17 +22,18 @@ class VicArticlesBusinessPagesStages implements PersisterStageInterface /** * VicArticlesBusinessPagesStages constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } /** * @param $payload CommandPayloadInterface + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -42,7 +42,6 @@ public function __invoke(CommandPayloadInterface $payload) $payload->getNewStageTitleMessage('Victoire BusinessPage generation:'); foreach ($payload->getNewVicBlog()->getArticles() as $article) { - $businessPage = null; if (null != $article->getId()) { @@ -59,7 +58,7 @@ public function __invoke(CommandPayloadInterface $payload) $overWriteWidgetMap = $payload->getParameter('article_content_widget_map'); $entityProxy = new EntityProxy(); - $entityProxy->setEntity($article, "article"); + $entityProxy->setEntity($article, 'article'); $this->entityManager->persist($entityProxy); $widgetMapCKEditor = new WidgetMap(); @@ -90,7 +89,7 @@ public function __invoke(CommandPayloadInterface $payload) $businessPage->setParent($payload->getNewVicBlog()); $businessPage->addWidgetMap($widgetMapCKEditor); $businessPage->setEntityProxy($entityProxy); - $businessPage->setStatus("published"); + $businessPage->setStatus('published'); $this->entityManager->persist($businessPage); $progress->advance(); @@ -100,9 +99,9 @@ public function __invoke(CommandPayloadInterface $payload) $this->entityManager->persist($payload->getNewVicBlog()); $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/SEO/VicSEOGenerator.php b/Pipeline/WordPress/Stages/SEO/VicSEOGenerator.php index 6a248c8..2de2a69 100644 --- a/Pipeline/WordPress/Stages/SEO/VicSEOGenerator.php +++ b/Pipeline/WordPress/Stages/SEO/VicSEOGenerator.php @@ -4,8 +4,8 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\SeoBundle\Entity\PageSeo; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Utils\Xml\XmlDataFormater; class VicSEOGenerator implements PersisterStageInterface @@ -17,6 +17,7 @@ class VicSEOGenerator implements PersisterStageInterface /** * VicSEOGenerator constructor. + * * @param EntityManager $entityManager */ public function __construct(EntityManager $entityManager) @@ -26,12 +27,13 @@ public function __construct(EntityManager $entityManager) /** * @param CommandPayloadInterface $payload + * * @return CommandPayloadInterface */ public function __invoke(CommandPayloadInterface $payload) { $xmlDataFormater = new XmlDataFormater(); - $articles = $this->entityManager->getRepository('VictoireBlogBundle:Article')->findBy(["blog" => $payload->getNewVicBlog()]); + $articles = $this->entityManager->getRepository('VictoireBlogBundle:Article')->findBy(['blog' => $payload->getNewVicBlog()]); $progress = $payload->getNewProgressBar(); $payload->getNewStageTitleMessage('Victoire SEO generation:'); @@ -40,16 +42,14 @@ public function __invoke(CommandPayloadInterface $payload) $seo = null; foreach ($payload->getRawData()->channel as $blog) { foreach ($blog->item as $wpArticle) { - if ($article->getName() == $xmlDataFormater->formatString('title', $wpArticle) ) { - + if ($article->getName() == $xmlDataFormater->formatString('title', $wpArticle)) { $seo = self::generateNewSEOPage($payload, $wpArticle, $xmlDataFormater, $article); if (null != $seo) { - if (null != $article->getTags()) { - $keyword = ""; + $keyword = ''; foreach ($article->getTags() as $tag) { - $keyword .= $tag->getTitle() . ","; + $keyword .= $tag->getTitle().','; } $seo->setKeyword($keyword, $payload->getNewVicBlog()->getDefaultLocale()); } @@ -73,8 +73,9 @@ public function __invoke(CommandPayloadInterface $payload) } } } - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); + return $payload; } @@ -83,6 +84,7 @@ public function __invoke(CommandPayloadInterface $payload) * @param $wpArticle * @param $xmlDataFormater * @param $article + * * @return null|PageSeo */ private function generateNewSEOPage(CommandPayloadInterface $payload, $wpArticle, XmlDataFormater $xmlDataFormater, $article) @@ -91,59 +93,58 @@ private function generateNewSEOPage(CommandPayloadInterface $payload, $wpArticle $seo = new PageSeo(); $seo->setDefaultLocale($payload->getNewVicBlog()->getDefaultLocale()); foreach ($wpArticle->postmeta as $meta) { - $key = $xmlDataFormater->formatString('meta_key', $meta); $value = $xmlDataFormater->formatString('meta_value', $meta); switch ($key) { - case ("_yoast_wpseo_title"): + case '_yoast_wpseo_title': $seo->setMetaTitle($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_metadesc"): + case '_yoast_wpseo_metadesc': $seo->setMetaDescription($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_meta-robots-noindex"): - $value = (boolean)$value; + case '_yoast_wpseo_meta-robots-noindex': + $value = (bool) $value; if ($value) { - $value = "index"; + $value = 'index'; } else { - $value = "noindex"; + $value = 'noindex'; } $seo->setMetaRobotsIndex($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_meta-robots-nofollow"): - $value = (boolean)$value; + case '_yoast_wpseo_meta-robots-nofollow': + $value = (bool) $value; if ($value) { - $value = "follow"; + $value = 'follow'; } else { - $value = "nofollow"; + $value = 'nofollow'; } $seo->setMetaRobotsFollow($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_meta-robots-adv"): - if ($value == "none") { + case '_yoast_wpseo_meta-robots-adv': + if ($value == 'none') { $value = null; } $seo->setMetaRobotsAdvanced($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_sitemap-include"): - if ($value != "-") { - $value = (boolean)$value; + case '_yoast_wpseo_sitemap-include': + if ($value != '-') { + $value = (bool) $value; $seo->setSitemapIndexed($value, $payload->getNewVicBlog()->getDefaultLocale()); } break; - case ("_yoast_wpseo_sitemap-prio"): - if ($value != "-") { + case '_yoast_wpseo_sitemap-prio': + if ($value != '-') { $seo->setSitemapPriority($value, $payload->getNewVicBlog()->getDefaultLocale()); } break; - case ("_yoast_wpseo_canonical"): + case '_yoast_wpseo_canonical': $seo->setRelCanonical($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_yoast_wpseo_opengraph-description"): + case '_yoast_wpseo_opengraph-description': $seo->setOgDescription($value, $payload->getNewVicBlog()->getDefaultLocale()); break; - case ("_thumbnail_id"): + case '_thumbnail_id': $seo->setOgImage($article->getImage(), $payload->getNewVicBlog()->getDefaultLocale()); break; } @@ -154,4 +155,4 @@ private function generateNewSEOPage(CommandPayloadInterface $payload, $wpArticle return $seo; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Tag/TagDataExtractorStages.php b/Pipeline/WordPress/Stages/Tag/TagDataExtractorStages.php index a5cba5f..6f55c35 100644 --- a/Pipeline/WordPress/Stages/Tag/TagDataExtractorStages.php +++ b/Pipeline/WordPress/Stages/Tag/TagDataExtractorStages.php @@ -3,20 +3,20 @@ namespace Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Tag; use Victoire\DevTools\VacuumBundle\Entity\WordPress\Tag; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Utils\Xml\XmlDataFormater; /** - * Class TagDataExtractorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Tag + * Class TagDataExtractorStages. */ class TagDataExtractorStages implements StageInterface { /** - * Extract and add tag from raw Data to tmpBlog + * Extract and add tag from raw Data to tmpBlog. * * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) @@ -26,12 +26,12 @@ public function __invoke(CommandPayloadInterface $payload) $channel = $payload->getRawData()->channel; $progress = $payload->getNewProgressBar(count($channel->tag)); - $payload->getNewStageTitleMessage("Tag data extraction:"); + $payload->getNewStageTitleMessage('Tag data extraction:'); foreach ($channel->tag as $wpTag) { $tag = new Tag(); $tag->setId($xmlDataFormater->formatString('term_id', $wpTag)); - $tag->setXmlTag("tag"); + $tag->setXmlTag('tag'); $tag->setTagName($xmlDataFormater->formatString('tag_name', $wpTag)); $tag->setTagSlug($xmlDataFormater->formatString('tag_slug', $wpTag)); @@ -40,10 +40,11 @@ public function __invoke(CommandPayloadInterface $payload) } $progress->finish(); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); unset($xmlDataFormater); + return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStages.php b/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStages.php index 1cc1a74..6a6e00d 100644 --- a/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStages.php +++ b/Pipeline/WordPress/Stages/Tag/VicTagGeneratorStages.php @@ -4,12 +4,11 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BlogBundle\Entity\Tag; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; /** - * Class VicTagGeneratorStages - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Tag + * Class VicTagGeneratorStages. */ class VicTagGeneratorStages implements PersisterStageInterface { @@ -20,12 +19,12 @@ class VicTagGeneratorStages implements PersisterStageInterface /** * TagGeneratorStages constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } @@ -33,16 +32,16 @@ public function __construct( * Transfer tag form tmpBlog to Victoire blog. * * @param $payload + * * @return mixed */ public function __invoke(CommandPayloadInterface $payload) { $progress = $payload->getNewProgressBar(count($payload->getTmpBlog()->getTags())); - $payload->getNewStageTitleMessage("Victoire Tag generation:"); + $payload->getNewStageTitleMessage('Victoire Tag generation:'); $payload->getXMLHistoryManager()->reload(); foreach ($payload->getTmpBlog()->getTags() as $wpTag) { - $history = $payload->getXMLHistoryManager()->searchHistory($wpTag, Tag::class); if (null == $history) { @@ -56,9 +55,9 @@ public function __invoke(CommandPayloadInterface $payload) } } - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); return $payload; } -} \ No newline at end of file +} diff --git a/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilder.php b/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilder.php index 7d1aa84..3313a4b 100644 --- a/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilder.php +++ b/Pipeline/WordPress/Stages/Template/VicArticleTemplateBuilder.php @@ -5,15 +5,13 @@ use Doctrine\ORM\EntityManager; use Victoire\Bundle\BlogBundle\Entity\ArticleTemplate; use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap; -use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; -use Victoire\DevTools\VacuumBundle\Pipeline\StageInterface; use Victoire\DevTools\VacuumBundle\Payload\CommandPayloadInterface; +use Victoire\DevTools\VacuumBundle\Pipeline\PersisterStageInterface; use Victoire\Widget\CKEditorBundle\Entity\WidgetCKEditor; use Victoire\Widget\LayoutBundle\Entity\WidgetLayout; /** - * Class VicArticleTemplateBuilder - * @package Victoire\DevTools\VacuumBundle\Pipeline\WordPress\Stages\Template + * Class VicArticleTemplateBuilder. */ class VicArticleTemplateBuilder implements PersisterStageInterface { @@ -24,22 +22,24 @@ class VicArticleTemplateBuilder implements PersisterStageInterface /** * VicArticleTemplateBuilder constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } /** * @param $id + * * @return null|object|\Victoire\Bundle\TemplateBundle\Entity\Template */ private function getTemplate($id) { $template = $this->entityManager->getRepository('VictoireTemplateBundle:Template')->find($id); + return $template; } @@ -57,9 +57,9 @@ public function __invoke(CommandPayloadInterface $payload) if ($parameters['new_article_template']) { $template = new ArticleTemplate(); - $template->setName("{{item.name}}", $payload->getNewVicBlog()->getDefaultLocale()); - $template->setSlug("{{item.slug}}", $payload->getNewVicBlog()->getDefaultLocale()); - $template->setBusinessEntityId("article"); + $template->setName('{{item.name}}', $payload->getNewVicBlog()->getDefaultLocale()); + $template->setSlug('{{item.slug}}', $payload->getNewVicBlog()->getDefaultLocale()); + $template->setBusinessEntityId('article'); $template->setBackendName($parameters['article_template_name']); $template->setLayout($parameters['article_template_layout']); $template->setParent($payload->getNewVicBlog()); @@ -80,12 +80,12 @@ public function __invoke(CommandPayloadInterface $payload) $widgetLayout = new WidgetLayout(); $widgetLayout->setWidgetMap($widgetMapLayout); - $widgetLayout->setLayoutMd("once"); + $widgetLayout->setLayoutMd('once'); $widgetLayout->setHasContainer(true); $widgetMapCKEditor = new WidgetMap(); $widgetMapCKEditor->setAction(WidgetMap::ACTION_CREATE); - $widgetMapCKEditor->setSlot($widgetLayout->getChildrenSlot()."_1"); + $widgetMapCKEditor->setSlot($widgetLayout->getChildrenSlot().'_1'); $widgetCKEditor = new WidgetCKEditor(); $widgetCKEditor->setWidgetMap($widgetMapCKEditor); @@ -99,10 +99,11 @@ public function __invoke(CommandPayloadInterface $payload) } } - $payload->addParameter("article_content_widget_map", $widgetMapCKEditor); + $payload->addParameter('article_content_widget_map', $widgetMapCKEditor); - $payload->getNewSuccessMessage(" success"); + $payload->getNewSuccessMessage(' success'); $payload->jumpLine(); + return $payload; } -} \ No newline at end of file +} diff --git a/Tests/Command/BlogImportCommandTest.php b/Tests/Command/BlogImportCommandTest.php index e88b0ff..090bd99 100644 --- a/Tests/Command/BlogImportCommandTest.php +++ b/Tests/Command/BlogImportCommandTest.php @@ -21,7 +21,7 @@ public function testExecute() $commandTester->execute([ 'command' => $command->getName(), - '--help' => '' + '--help' => '', ]); $output = $commandTester->getDisplay(); @@ -64,4 +64,4 @@ public function testExecute() If you want to disable any user interaction, use --no-interaction but don\'t forget to pass all needed options: ', $output); } -} \ No newline at end of file +} diff --git a/Utils/Curl/CurlsTools.php b/Utils/Curl/CurlsTools.php index 7761005..7e2dbc1 100644 --- a/Utils/Curl/CurlsTools.php +++ b/Utils/Curl/CurlsTools.php @@ -3,8 +3,7 @@ namespace Victoire\DevTools\VacuumBundle\Utils\Curl; /** - * Class CurlsTools - * @package Victoire\DevTools\VacuumBundle\Utils\Curl + * Class CurlsTools. */ class CurlsTools { @@ -15,12 +14,12 @@ class CurlsTools /** * CurlsTools constructor. + * * @param $kernelRootDir */ public function __construct( $kernelRootDir - ) - { + ) { $this->kernelRootDir = $kernelRootDir; } @@ -28,20 +27,20 @@ public function __construct( * @param $fileName * @param $directory * @param $distantPath + * * @return bool|string */ public function getDistantPicture($fileName, $distantPath) { try { - $filePath = sprintf( - "%s/../web/uploads/media/%s", + '%s/../web/uploads/media/%s', $this->kernelRootDir, $fileName ); if (!file_exists($filePath)) { - $lfile = fopen($filePath, "w"); + $lfile = fopen($filePath, 'w'); $header = header('Content-Type: text/html; charset=utf-8'); @@ -63,11 +62,10 @@ public function getDistantPicture($fileName, $distantPath) } return $filePath; - } catch (\Exception $e) { return false; } catch (\Throwable $e) { return false; } } -} \ No newline at end of file +} diff --git a/Utils/History/Exception/XMLHistoryException.php b/Utils/History/Exception/XMLHistoryException.php index c9c90c5..451f68a 100644 --- a/Utils/History/Exception/XMLHistoryException.php +++ b/Utils/History/Exception/XMLHistoryException.php @@ -4,5 +4,4 @@ class XMLHistoryException extends \Exception { - -} \ No newline at end of file +} diff --git a/Utils/History/HistoryManagerInterface.php b/Utils/History/HistoryManagerInterface.php index f322fca..73e17d5 100644 --- a/Utils/History/HistoryManagerInterface.php +++ b/Utils/History/HistoryManagerInterface.php @@ -8,36 +8,39 @@ use Victoire\DevTools\VacuumBundle\Utils\History\Exception\XMLHistoryException; /** - * Class ReaderInterface - * @package Victoire\DevTools\VacuumBundle\Utils\History + * Class ReaderInterface. */ interface HistoryManagerInterface { /** * ReaderInterface constructor. + * * @param EntityManager $entityManager */ public function __construct(EntityManager $entityManager); /** - * Only this function should be used to reload History + * Only this function should be used to reload History. */ public function reload(); /** * Search History entry by xmlTag and dump id * return null if nothing found or - * return VacuumXMLRelationHistory Entity + * return VacuumXMLRelationHistory Entity. * * @param AbstractXMLEntity $source + * * @return mixed */ public function searchHistory(AbstractXMLEntity $source, $vicClass); /** * @param AbstractVacuumRelationHistory $history - * @return null|object + * * @throws XMLHistoryException + * + * @return null|object */ public function getVicEntity(AbstractVacuumRelationHistory $history); -} \ No newline at end of file +} diff --git a/Utils/History/XMLHistoryManager.php b/Utils/History/XMLHistoryManager.php index 11cdb59..815aa83 100644 --- a/Utils/History/XMLHistoryManager.php +++ b/Utils/History/XMLHistoryManager.php @@ -22,30 +22,30 @@ class XMLHistoryManager implements HistoryManagerInterface /** * Reader constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager - ) - { + ) { $this->entityManager = $entityManager; } /** - * Reload Histories + * Reload Histories. */ public function reload() { unset($this->histories); $this->histories = $this->entityManager ->getRepository('VictoireVacuumBundle:VacuumXMlRelationHistory') - ->findAll() - ; + ->findAll(); } /** * @param AbstractXMLEntity $source * @param $vicClass + * * @return mixed|null|VacuumXMlRelationHistory */ public function searchHistory(AbstractXMLEntity $source, $vicClass) @@ -58,14 +58,14 @@ public function searchHistory(AbstractXMLEntity $source, $vicClass) return $history; } } - - return null; } /** * @param AbstractVacuumRelationHistory $history - * @return null|object + * * @throws XMLHistoryException + * + * @return null|object */ public function getVicEntity(AbstractVacuumRelationHistory $history) { @@ -86,6 +86,7 @@ public function getVicEntity(AbstractVacuumRelationHistory $history) /** * @param AbstractXMLEntity $source * @param $refined + * * @return VacuumXMlRelationHistory */ public function generateHistory(AbstractXMLEntity $source, $refined) @@ -113,4 +114,4 @@ public function flushHistory($entity, VacuumXMlRelationHistory $history) $this->entityManager->persist($history); $this->entityManager->flush(); } -} \ No newline at end of file +} diff --git a/Utils/Media/MediaFormater.php b/Utils/Media/MediaFormater.php index eb48257..ec1bb2e 100644 --- a/Utils/Media/MediaFormater.php +++ b/Utils/Media/MediaFormater.php @@ -27,14 +27,14 @@ class MediaFormater /** * MediaFormater constructor. + * * @param EntityManager $entityManager */ public function __construct( EntityManager $entityManager, $kernelRootDir, CurlsTools $curlsTools - ) - { + ) { $this->entityManager = $entityManager; $this->kernelRootDir = $kernelRootDir; $this->curlsTools = $curlsTools; @@ -42,12 +42,13 @@ public function __construct( /** * @param $payload + * * @return mixed */ public function generateBlogFolder(CommandPayloadInterface $payload) { if (null == $payload->getTmpBlog()->getBlogFolder()) { - $blogFolder = $this->generateFoler("blog"); + $blogFolder = $this->generateFoler('blog'); $payload->getTmpBlog()->setBlogFolder($blogFolder); } else { $blogFolder = $payload->getTmpBlog()->getBlogFolder(); @@ -58,18 +59,19 @@ public function generateBlogFolder(CommandPayloadInterface $payload) /** * @param $distantPath + * * @return mixed|string */ public function cleanUrl($distantPath) { $distantPath = trim($distantPath); $url = parse_url($distantPath); - $distantPath = sprintf("%s://%s%s", + $distantPath = sprintf('%s://%s%s', $url['scheme'], $url['host'], urlencode($url['path']) ); - $distantPath = str_replace("%2F","/", $distantPath); + $distantPath = str_replace('%2F', '/', $distantPath); return $distantPath; } @@ -77,21 +79,22 @@ public function cleanUrl($distantPath) /** * @param $newFolderName * @param $parentFolderName + * * @return mixed */ public function generateFoler($newFolderName, $parentFolderName = null) { - if (!file_exists($this->kernelRootDir."/../web/uploads/media")) { - mkdir($this->kernelRootDir."/../web/uploads/media", 0777, true); + if (!file_exists($this->kernelRootDir.'/../web/uploads/media')) { + mkdir($this->kernelRootDir.'/../web/uploads/media', 0777, true); } $folder = new Folder(); - $folder->setName($newFolderName != null ? $newFolderName : "unknown"); + $folder->setName($newFolderName != null ? $newFolderName : 'unknown'); if ($parentFolderName == null) { - $parentFolderName = $this->entityManager->getRepository("VictoireMediaBundle:Folder")->find(1); + $parentFolderName = $this->entityManager->getRepository('VictoireMediaBundle:Folder')->find(1); } $folder->setParent($parentFolderName); - $folder->setRel("media"); + $folder->setRel('media'); $this->entityManager->persist($folder); return $folder; @@ -99,34 +102,35 @@ public function generateFoler($newFolderName, $parentFolderName = null) /** * @param $path + * * @return Media */ public function generateImageMedia($path, Folder $folder) { if (null != $path) { - $attachment = new Media(); $distantPath = $path; - $fileName = explode("/", $distantPath); + $fileName = explode('/', $distantPath); $fileName = end($fileName); $attachment->setName($fileName); $fileExtension = null; - $fileExtension = explode(".", $fileName); + $fileExtension = explode('.', $fileName); $fileExtension = end($fileExtension); // this persist will generate the uuid for attachment $this->entityManager->persist($attachment); - $fileName = $attachment->getUuid().".".$fileExtension; + $fileName = $attachment->getUuid().'.'.$fileExtension; $filePath = $this->curlsTools->getDistantPicture($fileName, $distantPath); $finfo = finfo_open(FILEINFO_MIME_TYPE); $attachment->setContentType(finfo_file($finfo, $filePath)); - $attachment->setLocation("local"); + $attachment->setLocation('local'); $attachment->setUrl('/uploads/media/'.$fileName); $attachment->setFolder($folder); $this->entityManager->persist($attachment); + return $attachment; } } -} \ No newline at end of file +} diff --git a/Utils/Xml/XmlDataFormater.php b/Utils/Xml/XmlDataFormater.php index 02fc3c9..adc8327 100644 --- a/Utils/Xml/XmlDataFormater.php +++ b/Utils/Xml/XmlDataFormater.php @@ -3,14 +3,14 @@ namespace Victoire\DevTools\VacuumBundle\Utils\Xml; /** - * Class XmlDataFormater - * @package Victoire\DevTools\VacuumBundle\Utils\Xml + * Class XmlDataFormater. */ class XmlDataFormater { /** * @param $node * @param $simpleXml + * * @return null|string */ public function formatString($node, $simpleXml) @@ -18,13 +18,12 @@ public function formatString($node, $simpleXml) if (!empty($simpleXml->$node)) { return (string) $simpleXml->$node; } - - return null; } /** * @param $node * @param $simpleXml + * * @return \DateTime|null|string */ public function formatDate($node, $simpleXml) @@ -32,23 +31,21 @@ public function formatDate($node, $simpleXml) $date = $this->formatString($node, $simpleXml); if (null != $date) { $date = new \DateTime($date); + return $date; } - - return null; } /** * @param $node * @param $simpleXml + * * @return int|null */ public function formatInteger($node, $simpleXml) { if (!empty($simpleXml->$node)) { - return (integer) $simpleXml->$node; + return (int) $simpleXml->$node; } - - return null; } -} \ No newline at end of file +}