From 6bc6fb1f60e7b81a21f844dca025671a2f4a4564 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 27 May 2017 22:08:14 +0200 Subject: Move Tags assigner to a separate file Signed-off-by: Thomas Citharel --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 8bf7d92e..c8a9b4e6 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -205,7 +205,7 @@ abstract class BrowserImport extends AbstractImport $entry = $this->fetchContent($entry, $data['url'], $data); if (array_key_exists('tags', $data)) { - $this->contentProxy->assignTagsToEntry( + $this->tagsAssigner->assignTagsToEntry( $entry, $data['tags'] ); -- cgit v1.2.3 From 5d3deafd3efc04df53fc24ee82a49988f72756dd Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 28 May 2017 01:16:01 +0200 Subject: CS Signed-off-by: Thomas Citharel --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index c8a9b4e6..ef0eeb7e 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -4,7 +4,6 @@ namespace Wallabag\ImportBundle\Import; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\UserBundle\Entity\User; -use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Event\EntrySavedEvent; abstract class BrowserImport extends AbstractImport -- cgit v1.2.3 From 7aba665e484c5c36ee029219a999a427d864ff22 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Tue, 6 Dec 2016 22:17:44 -0500 Subject: Avoid returning objects passed by reference. Objects are always passed by reference, so it doesn't make sense to return an object which is passed by reference as it will always be the same object. This change makes the code a bit more readable. --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index ef0eeb7e..71e65e59 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -201,7 +201,7 @@ abstract class BrowserImport extends AbstractImport $entry->setTitle($data['title']); // update entry with content (in case fetching failed, the given entry will be return) - $entry = $this->fetchContent($entry, $data['url'], $data); + $this->fetchContent($entry, $data['url'], $data); if (array_key_exists('tags', $data)) { $this->tagsAssigner->assignTagsToEntry( -- cgit v1.2.3 From f808b01692a835673f328d7221ba8c212caa9b61 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 1 Jul 2017 09:52:38 +0200 Subject: Add a real configuration for CS-Fixer --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 150 ++++++++++----------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 71e65e59..f1195824 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -3,8 +3,8 @@ namespace Wallabag\ImportBundle\Import; use Wallabag\CoreBundle\Entity\Entry; -use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Event\EntrySavedEvent; +use Wallabag\UserBundle\Entity\User; abstract class BrowserImport extends AbstractImport { @@ -73,6 +73,80 @@ abstract class BrowserImport extends AbstractImport return $this; } + /** + * {@inheritdoc} + */ + public function parseEntry(array $importedEntry) + { + if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry); + + return; + } + + $this->parseEntries($importedEntry); + + return; + } + + if (array_key_exists('children', $importedEntry)) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry['children']); + + return; + } + + $this->parseEntries($importedEntry['children']); + + return; + } + + if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) { + return; + } + + $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; + + $existingEntry = $this->em + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($url, $this->user->getId()); + + if (false !== $existingEntry) { + ++$this->skippedEntries; + + return; + } + + $data = $this->prepareEntry($importedEntry); + + $entry = new Entry($this->user); + $entry->setUrl($data['url']); + $entry->setTitle($data['title']); + + // update entry with content (in case fetching failed, the given entry will be return) + $this->fetchContent($entry, $data['url'], $data); + + if (array_key_exists('tags', $data)) { + $this->tagsAssigner->assignTagsToEntry( + $entry, + $data['tags'] + ); + } + + $entry->setArchived($data['is_archived']); + + if (!empty($data['created_at'])) { + $dt = new \DateTime(); + $entry->setCreatedAt($dt->setTimestamp($data['created_at'])); + } + + $this->em->persist($entry); + ++$this->importedEntries; + + return $entry; + } + /** * Parse and insert all given entries. * @@ -149,80 +223,6 @@ abstract class BrowserImport extends AbstractImport } } - /** - * {@inheritdoc} - */ - public function parseEntry(array $importedEntry) - { - if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) { - if ($this->producer) { - $this->parseEntriesForProducer($importedEntry); - - return; - } - - $this->parseEntries($importedEntry); - - return; - } - - if (array_key_exists('children', $importedEntry)) { - if ($this->producer) { - $this->parseEntriesForProducer($importedEntry['children']); - - return; - } - - $this->parseEntries($importedEntry['children']); - - return; - } - - if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) { - return; - } - - $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; - - $existingEntry = $this->em - ->getRepository('WallabagCoreBundle:Entry') - ->findByUrlAndUserId($url, $this->user->getId()); - - if (false !== $existingEntry) { - ++$this->skippedEntries; - - return; - } - - $data = $this->prepareEntry($importedEntry); - - $entry = new Entry($this->user); - $entry->setUrl($data['url']); - $entry->setTitle($data['title']); - - // update entry with content (in case fetching failed, the given entry will be return) - $this->fetchContent($entry, $data['url'], $data); - - if (array_key_exists('tags', $data)) { - $this->tagsAssigner->assignTagsToEntry( - $entry, - $data['tags'] - ); - } - - $entry->setArchived($data['is_archived']); - - if (!empty($data['created_at'])) { - $dt = new \DateTime(); - $entry->setCreatedAt($dt->setTimestamp($data['created_at'])); - } - - $this->em->persist($entry); - ++$this->importedEntries; - - return $entry; - } - /** * {@inheritdoc} */ -- cgit v1.2.3 From 52b84c11a5b5474cd45271d937a46c6adfdf2749 Mon Sep 17 00:00:00 2001 From: Nicolas Hart Date: Sat, 29 Jul 2017 22:51:50 +0200 Subject: Fix some namespaces and phpdoc --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index f1195824..1628cb47 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -4,7 +4,6 @@ namespace Wallabag\ImportBundle\Import; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Event\EntrySavedEvent; -use Wallabag\UserBundle\Entity\User; abstract class BrowserImport extends AbstractImport { -- cgit v1.2.3 From fe312015d2902dcc2e08b02ab4307da5c206217a Mon Sep 17 00:00:00 2001 From: Nicolas Hart Date: Sat, 29 Jul 2017 22:59:11 +0200 Subject: Add missing abstract method prepareEntry in BrowserImport --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index f1195824..4d3073b7 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -232,4 +232,6 @@ abstract class BrowserImport extends AbstractImport return $importedEntry; } + + abstract protected function prepareEntry(array $entry = []); } -- cgit v1.2.3 From 3ef055ced3d6ea0d2f15ba660602545f477e9c3c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 9 Oct 2017 16:47:15 +0200 Subject: CS --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/ImportBundle/Import/BrowserImport.php') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 78077324..b5593180 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -171,7 +171,7 @@ abstract class BrowserImport extends AbstractImport $entryToBeFlushed[] = $entry; // flush every 20 entries - if (($i % 20) === 0) { + if (0 === ($i % 20)) { $this->em->flush(); foreach ($entryToBeFlushed as $entry) { -- cgit v1.2.3