aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-07-03 13:39:54 +0200
committerGitHub <noreply@github.com>2017-07-03 13:39:54 +0200
commit71e1cbc8eb5928d393b0772055d6b711e90a09b3 (patch)
tree71795eadcf13fda9198b8cd9a3da26d51826bbd9 /src/Wallabag
parent822c877949aff8ae57677671115f8f4fc69588d5 (diff)
parent38520658addc217f127b0627ea28dcf8d6e6178c (diff)
downloadwallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.tar.gz
wallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.tar.zst
wallabag-71e1cbc8eb5928d393b0772055d6b711e90a09b3.zip
Merge pull request #3258 from wallabag/cs-fixer
Add a real configuration for CS-Fixer
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php2
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php10
-rw-r--r--src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php32
-rw-r--r--src/Wallabag/ApiBundle/Controller/AnnotationRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/DeveloperController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php18
-rw-r--r--src/Wallabag/ApiBundle/Controller/TagRestController.php2
-rw-r--r--src/Wallabag/ApiBundle/Controller/UserRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Entity/Client.php4
-rw-r--r--src/Wallabag/ApiBundle/Form/Type/ClientType.php2
-rw-r--r--src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php4
-rw-r--r--src/Wallabag/CoreBundle/Command/ExportCommand.php2
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php22
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php140
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php260
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExceptionController.php2
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php4
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php18
-rw-r--r--src/Wallabag/CoreBundle/Controller/SiteCredentialController.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php7
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php2
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php2
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php10
-rw-r--r--src/Wallabag/CoreBundle/Entity/SiteCredential.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php2
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php8
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php2
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php4
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php16
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php4
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php10
-rw-r--r--src/Wallabag/CoreBundle/Helper/CryptoProxy.php12
-rw-r--r--src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php44
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php46
-rw-r--r--src/Wallabag/CoreBundle/Helper/HttpClientFactory.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php2
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php38
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php12
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php10
-rw-r--r--src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php12
-rw-r--r--src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php10
-rw-r--r--src/Wallabag/ImportBundle/Controller/BrowserController.php43
-rw-r--r--src/Wallabag/ImportBundle/Controller/ChromeController.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/FirefoxController.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php6
-rw-r--r--src/Wallabag/ImportBundle/Controller/InstapaperController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/PinboardController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php46
-rw-r--r--src/Wallabag/ImportBundle/Controller/ReadabilityController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagController.php46
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php16
-rw-r--r--src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php6
-rw-r--r--src/Wallabag/ImportBundle/Form/Type/UploadImportType.php6
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php52
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php150
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/ImportCompilerPass.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php13
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php4
-rw-r--r--src/Wallabag/ImportBundle/Redis/Producer.php2
-rw-r--r--src/Wallabag/ImportBundle/WallabagImportBundle.php2
-rw-r--r--src/Wallabag/UserBundle/Controller/ManageController.php48
-rw-r--r--src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php6
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php36
-rw-r--r--src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php2
-rw-r--r--src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php2
-rw-r--r--src/Wallabag/UserBundle/Form/UserType.php10
-rw-r--r--src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php2
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php2
76 files changed, 705 insertions, 720 deletions
diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
index 2b4b0e8d..8d7b6ee9 100644
--- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
+++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
@@ -3,9 +3,9 @@
3namespace Wallabag\AnnotationBundle\Controller; 3namespace Wallabag\AnnotationBundle\Controller;
4 4
5use FOS\RestBundle\Controller\FOSRestController; 5use FOS\RestBundle\Controller\FOSRestController;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
6use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
7use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
9use Wallabag\AnnotationBundle\Entity\Annotation; 9use Wallabag\AnnotationBundle\Entity\Annotation;
10use Wallabag\AnnotationBundle\Form\EditAnnotationType; 10use Wallabag\AnnotationBundle\Form\EditAnnotationType;
11use Wallabag\AnnotationBundle\Form\NewAnnotationType; 11use Wallabag\AnnotationBundle\Form\NewAnnotationType;
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
index c8e41649..04d83001 100644
--- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -3,14 +3,14 @@
3namespace Wallabag\AnnotationBundle\Entity; 3namespace Wallabag\AnnotationBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\ExclusionPolicy;
7use JMS\Serializer\Annotation\Exclude; 6use JMS\Serializer\Annotation\Exclude;
8use JMS\Serializer\Annotation\VirtualProperty; 7use JMS\Serializer\Annotation\ExclusionPolicy;
9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\Groups; 8use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\VirtualProperty;
11use Symfony\Component\Validator\Constraints as Assert; 11use Symfony\Component\Validator\Constraints as Assert;
12use Wallabag\UserBundle\Entity\User;
13use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
13use Wallabag\UserBundle\Entity\User;
14 14
15/** 15/**
16 * Annotation. 16 * Annotation.
@@ -139,7 +139,7 @@ class Annotation
139 */ 139 */
140 public function timestamps() 140 public function timestamps()
141 { 141 {
142 if (is_null($this->createdAt)) { 142 if (null === $this->createdAt) {
143 $this->createdAt = new \DateTime(); 143 $this->createdAt = new \DateTime();
144 } 144 }
145 $this->updatedAt = new \DateTime(); 145 $this->updatedAt = new \DateTime();
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
index da361308..014c29b6 100644
--- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
+++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
@@ -10,22 +10,6 @@ use Doctrine\ORM\EntityRepository;
10class AnnotationRepository extends EntityRepository 10class AnnotationRepository extends EntityRepository
11{ 11{
12 /** 12 /**
13 * Return a query builder to used by other getBuilderFor* method.
14 *
15 * @param int $userId
16 *
17 * @return QueryBuilder
18 */
19 private function getBuilderByUser($userId)
20 {
21 return $this->createQueryBuilder('a')
22 ->leftJoin('a.user', 'u')
23 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
24 ->orderBy('a.id', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all annotations for a user. 13 * Retrieves all annotations for a user.
30 * 14 *
31 * @param int $userId 15 * @param int $userId
@@ -139,4 +123,20 @@ class AnnotationRepository extends EntityRepository
139 ->getQuery() 123 ->getQuery()
140 ->getResult(); 124 ->getResult();
141 } 125 }
126
127 /**
128 * Return a query builder to used by other getBuilderFor* method.
129 *
130 * @param int $userId
131 *
132 * @return QueryBuilder
133 */
134 private function getBuilderByUser($userId)
135 {
136 return $this->createQueryBuilder('a')
137 ->leftJoin('a.user', 'u')
138 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
139 ->orderBy('a.id', 'desc')
140 ;
141 }
142} 142}
diff --git a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
index 2dd26c07..28d55ba9 100644
--- a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
@@ -4,10 +4,10 @@ namespace Wallabag\ApiBundle\Controller;
4 4
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
9use Wallabag\CoreBundle\Entity\Entry; 8use Symfony\Component\HttpFoundation\Request;
10use Wallabag\AnnotationBundle\Entity\Annotation; 9use Wallabag\AnnotationBundle\Entity\Annotation;
10use Wallabag\CoreBundle\Entity\Entry;
11 11
12class AnnotationRestController extends WallabagRestController 12class AnnotationRestController extends WallabagRestController
13{ 13{
diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php
index 9cb73f4c..c8a1c635 100644
--- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php
+++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php
@@ -3,8 +3,8 @@
3namespace Wallabag\ApiBundle\Controller; 3namespace Wallabag\ApiBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ApiBundle\Entity\Client; 8use Wallabag\ApiBundle\Entity\Client;
9use Wallabag\ApiBundle\Form\Type\ClientType; 9use Wallabag\ApiBundle\Form\Type\ClientType;
10 10
@@ -75,7 +75,7 @@ class DeveloperController extends Controller
75 */ 75 */
76 public function deleteClientAction(Client $client) 76 public function deleteClientAction(Client $client)
77 { 77 {
78 if (null === $this->getUser() || $client->getUser()->getId() != $this->getUser()->getId()) { 78 if (null === $this->getUser() || $client->getUser()->getId() !== $this->getUser()->getId()) {
79 throw $this->createAccessDeniedException('You can not access this client.'); 79 throw $this->createAccessDeniedException('You can not access this client.');
80 } 80 }
81 81
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index c7938633..ca460c84 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -6,14 +6,14 @@ use Hateoas\Configuration\Route;
6use Hateoas\Representation\Factory\PagerfantaFactory; 6use Hateoas\Representation\Factory\PagerfantaFactory;
7use JMS\Serializer\SerializationContext; 7use JMS\Serializer\SerializationContext;
8use Nelmio\ApiDocBundle\Annotation\ApiDoc; 8use Nelmio\ApiDocBundle\Annotation\ApiDoc;
9use Symfony\Component\HttpKernel\Exception\HttpException;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpFoundation\JsonResponse; 9use Symfony\Component\HttpFoundation\JsonResponse;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpKernel\Exception\HttpException;
12use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 12use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
13use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
14use Wallabag\CoreBundle\Entity\Tag; 14use Wallabag\CoreBundle\Entity\Tag;
15use Wallabag\CoreBundle\Event\EntrySavedEvent;
16use Wallabag\CoreBundle\Event\EntryDeletedEvent; 15use Wallabag\CoreBundle\Event\EntryDeletedEvent;
16use Wallabag\CoreBundle\Event\EntrySavedEvent;
17 17
18class EntryRestController extends WallabagRestController 18class EntryRestController extends WallabagRestController
19{ 19{
@@ -59,7 +59,7 @@ class EntryRestController extends WallabagRestController
59 $url = $request->query->get('url', ''); 59 $url = $request->query->get('url', '');
60 60
61 if (empty($url)) { 61 if (empty($url)) {
62 throw $this->createAccessDeniedException('URL is empty?, logged user id: '.$this->getUser()->getId()); 62 throw $this->createAccessDeniedException('URL is empty?, logged user id: ' . $this->getUser()->getId());
63 } 63 }
64 64
65 $res = $this->getDoctrine() 65 $res = $this->getDoctrine()
@@ -239,9 +239,9 @@ class EntryRestController extends WallabagRestController
239 * } 239 * }
240 * ) 240 * )
241 * 241 *
242 * @return JsonResponse
243 *
244 * @throws HttpException When limit is reached 242 * @throws HttpException When limit is reached
243 *
244 * @return JsonResponse
245 */ 245 */
246 public function postEntriesListAction(Request $request) 246 public function postEntriesListAction(Request $request)
247 { 247 {
@@ -678,11 +678,11 @@ class EntryRestController extends WallabagRestController
678 ]); 678 ]);
679 } 679 }
680 680
681 if (!is_null($isArchived)) { 681 if (null !== $isArchived) {
682 $entry->setArchived((bool) $isArchived); 682 $entry->setArchived((bool) $isArchived);
683 } 683 }
684 684
685 if (!is_null($isStarred)) { 685 if (null !== $isStarred) {
686 $entry->setStarred((bool) $isStarred); 686 $entry->setStarred((bool) $isStarred);
687 } 687 }
688 688
@@ -690,7 +690,7 @@ class EntryRestController extends WallabagRestController
690 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); 690 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
691 } 691 }
692 692
693 if (!is_null($isPublic)) { 693 if (null !== $isPublic) {
694 if (true === (bool) $isPublic && null === $entry->getUid()) { 694 if (true === (bool) $isPublic && null === $entry->getUid()) {
695 $entry->generateUid(); 695 $entry->generateUid();
696 } elseif (false === (bool) $isPublic) { 696 } elseif (false === (bool) $isPublic) {
diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php
index 354187a0..efa4e8cf 100644
--- a/src/Wallabag/ApiBundle/Controller/TagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php
@@ -3,8 +3,8 @@
3namespace Wallabag\ApiBundle\Controller; 3namespace Wallabag\ApiBundle\Controller;
4 4
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\HttpFoundation\JsonResponse; 6use Symfony\Component\HttpFoundation\JsonResponse;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 9use Wallabag\CoreBundle\Entity\Tag;
10 10
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php
index 7471f5f6..6f47cff0 100644
--- a/src/Wallabag/ApiBundle/Controller/UserRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php
@@ -6,10 +6,10 @@ use FOS\UserBundle\Event\UserEvent;
6use FOS\UserBundle\FOSUserEvents; 6use FOS\UserBundle\FOSUserEvents;
7use JMS\Serializer\SerializationContext; 7use JMS\Serializer\SerializationContext;
8use Nelmio\ApiDocBundle\Annotation\ApiDoc; 8use Nelmio\ApiDocBundle\Annotation\ApiDoc;
9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpFoundation\JsonResponse; 9use Symfony\Component\HttpFoundation\JsonResponse;
11use Wallabag\UserBundle\Entity\User; 10use Symfony\Component\HttpFoundation\Request;
12use Wallabag\ApiBundle\Entity\Client; 11use Wallabag\ApiBundle\Entity\Client;
12use Wallabag\UserBundle\Entity\User;
13 13
14class UserRestController extends WallabagRestController 14class UserRestController extends WallabagRestController
15{ 15{
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index b1e08ca4..71da2a64 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -40,8 +40,8 @@ class WallabagRestController extends FOSRestController
40 protected function validateUserAccess($requestUserId) 40 protected function validateUserAccess($requestUserId)
41 { 41 {
42 $user = $this->get('security.token_storage')->getToken()->getUser(); 42 $user = $this->get('security.token_storage')->getToken()->getUser();
43 if ($requestUserId != $user->getId()) { 43 if ($requestUserId !== $user->getId()) {
44 throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId()); 44 throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
45 } 45 }
46 } 46 }
47} 47}
diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php
index c15fd3fa..e6f98f98 100644
--- a/src/Wallabag/ApiBundle/Entity/Client.php
+++ b/src/Wallabag/ApiBundle/Entity/Client.php
@@ -4,10 +4,10 @@ namespace Wallabag\ApiBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use FOS\OAuthServerBundle\Entity\Client as BaseClient; 6use FOS\OAuthServerBundle\Entity\Client as BaseClient;
7use Wallabag\UserBundle\Entity\User;
8use JMS\Serializer\Annotation\Groups; 7use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\SerializedName; 8use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\VirtualProperty; 9use JMS\Serializer\Annotation\VirtualProperty;
10use Wallabag\UserBundle\Entity\User;
11 11
12/** 12/**
13 * @ORM\Table("oauth2_clients") 13 * @ORM\Table("oauth2_clients")
@@ -99,6 +99,6 @@ class Client extends BaseClient
99 */ 99 */
100 public function getClientId() 100 public function getClientId()
101 { 101 {
102 return $this->getId().'_'.$this->getRandomId(); 102 return $this->getId() . '_' . $this->getRandomId();
103 } 103 }
104} 104}
diff --git a/src/Wallabag/ApiBundle/Form/Type/ClientType.php b/src/Wallabag/ApiBundle/Form/Type/ClientType.php
index eaea4feb..fc22538f 100644
--- a/src/Wallabag/ApiBundle/Form/Type/ClientType.php
+++ b/src/Wallabag/ApiBundle/Form/Type/ClientType.php
@@ -5,8 +5,8 @@ namespace Wallabag\ApiBundle\Form\Type;
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\CallbackTransformer; 6use Symfony\Component\Form\CallbackTransformer;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType; 7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\UrlType;
9use Symfony\Component\Form\Extension\Core\Type\TextType; 8use Symfony\Component\Form\Extension\Core\Type\TextType;
9use Symfony\Component\Form\Extension\Core\Type\UrlType;
10use Symfony\Component\Form\FormBuilderInterface; 10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver; 11use Symfony\Component\OptionsResolver\OptionsResolver;
12 12
diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
index 74da1e5f..d964439d 100644
--- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
@@ -76,7 +76,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
76 $url = $this->similarUrl($entry['url']); 76 $url = $this->similarUrl($entry['url']);
77 77
78 /* @var $entry Entry */ 78 /* @var $entry Entry */
79 if (in_array($url, $urls)) { 79 if (in_array($url, $urls, true)) {
80 ++$duplicatesCount; 80 ++$duplicatesCount;
81 81
82 $em->remove($repo->find($entry['id'])); 82 $em->remove($repo->find($entry['id']));
@@ -93,7 +93,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
93 93
94 private function similarUrl($url) 94 private function similarUrl($url)
95 { 95 {
96 if (in_array(substr($url, -1), ['/', '#'])) { // get rid of "/" and "#" and the end of urls 96 if (in_array(substr($url, -1), ['/', '#'], true)) { // get rid of "/" and "#" and the end of urls
97 return substr($url, 0, strlen($url)); 97 return substr($url, 0, strlen($url));
98 } 98 }
99 99
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php
index ebb2b4cf..0dacb734 100644
--- a/src/Wallabag/CoreBundle/Command/ExportCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php
@@ -49,7 +49,7 @@ class ExportCommand extends ContainerAwareCommand
49 $filePath = $input->getArgument('filepath'); 49 $filePath = $input->getArgument('filepath');
50 50
51 if (!$filePath) { 51 if (!$filePath) {
52 $filePath = $this->getContainer()->getParameter('kernel.root_dir').'/../'.sprintf('%s-export.json', $user->getUsername()); 52 $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export.json', $user->getUsername());
53 } 53 }
54 54
55 try { 55 try {
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index eb725a59..50551480 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -2,6 +2,7 @@
2 2
3namespace Wallabag\CoreBundle\Command; 3namespace Wallabag\CoreBundle\Command;
4 4
5use Craue\ConfigBundle\Entity\Setting;
5use FOS\UserBundle\Event\UserEvent; 6use FOS\UserBundle\Event\UserEvent;
6use FOS\UserBundle\FOSUserEvents; 7use FOS\UserBundle\FOSUserEvents;
7use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 8use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
@@ -14,7 +15,6 @@ use Symfony\Component\Console\Output\OutputInterface;
14use Symfony\Component\Console\Question\ConfirmationQuestion; 15use Symfony\Component\Console\Question\ConfirmationQuestion;
15use Symfony\Component\Console\Question\Question; 16use Symfony\Component\Console\Question\Question;
16use Wallabag\CoreBundle\Entity\Config; 17use Wallabag\CoreBundle\Entity\Config;
17use Craue\ConfigBundle\Entity\Setting;
18 18
19class InstallCommand extends ContainerAwareCommand 19class InstallCommand extends ContainerAwareCommand
20{ 20{
@@ -86,7 +86,7 @@ class InstallCommand extends ContainerAwareCommand
86 if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) { 86 if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) {
87 $fulfilled = false; 87 $fulfilled = false;
88 $status = '<error>ERROR!</error>'; 88 $status = '<error>ERROR!</error>';
89 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; 89 $help = 'Database driver "' . $this->getContainer()->getParameter('database_driver') . '" is not installed.';
90 } 90 }
91 91
92 $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help]; 92 $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help];
@@ -101,10 +101,10 @@ class InstallCommand extends ContainerAwareCommand
101 $conn->connect(); 101 $conn->connect();
102 } catch (\Exception $e) { 102 } catch (\Exception $e) {
103 if (false === strpos($e->getMessage(), 'Unknown database') 103 if (false === strpos($e->getMessage(), 'Unknown database')
104 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { 104 && false === strpos($e->getMessage(), 'database "' . $this->getContainer()->getParameter('database_name') . '" does not exist')) {
105 $fulfilled = false; 105 $fulfilled = false;
106 $status = '<error>ERROR!</error>'; 106 $status = '<error>ERROR!</error>';
107 $help = 'Can\'t connect to the database: '.$e->getMessage(); 107 $help = 'Can\'t connect to the database: ' . $e->getMessage();
108 } 108 }
109 } 109 }
110 110
@@ -123,7 +123,7 @@ class InstallCommand extends ContainerAwareCommand
123 if (false === version_compare($version, $minimalVersion, '>')) { 123 if (false === version_compare($version, $minimalVersion, '>')) {
124 $fulfilled = false; 124 $fulfilled = false;
125 $status = '<error>ERROR!</error>'; 125 $status = '<error>ERROR!</error>';
126 $help = 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).'; 126 $help = 'Your MySQL version (' . $version . ') is too old, consider upgrading (' . $minimalVersion . '+).';
127 } 127 }
128 } 128 }
129 129
@@ -137,21 +137,21 @@ class InstallCommand extends ContainerAwareCommand
137 if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) { 137 if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) {
138 $fulfilled = false; 138 $fulfilled = false;
139 $status = '<error>ERROR!</error>'; 139 $status = '<error>ERROR!</error>';
140 $help = 'PostgreSQL should be greater than 9.1 (actual version: '.$matches[1].')'; 140 $help = 'PostgreSQL should be greater than 9.1 (actual version: ' . $matches[1] . ')';
141 } 141 }
142 } 142 }
143 143
144 $rows[] = [$label, $status, $help]; 144 $rows[] = [$label, $status, $help];
145 145
146 foreach ($this->functionExists as $functionRequired) { 146 foreach ($this->functionExists as $functionRequired) {
147 $label = '<comment>'.$functionRequired.'</comment>'; 147 $label = '<comment>' . $functionRequired . '</comment>';
148 $status = '<info>OK!</info>'; 148 $status = '<info>OK!</info>';
149 $help = ''; 149 $help = '';
150 150
151 if (!function_exists($functionRequired)) { 151 if (!function_exists($functionRequired)) {
152 $fulfilled = false; 152 $fulfilled = false;
153 $status = '<error>ERROR!</error>'; 153 $status = '<error>ERROR!</error>';
154 $help = 'You need the '.$functionRequired.' function activated'; 154 $help = 'You need the ' . $functionRequired . ' function activated';
155 } 155 }
156 156
157 $rows[] = [$label, $status, $help]; 157 $rows[] = [$label, $status, $help];
@@ -351,8 +351,8 @@ class InstallCommand extends ContainerAwareCommand
351 $this->getApplication()->setAutoExit(true); 351 $this->getApplication()->setAutoExit(true);
352 352
353 throw new \RuntimeException( 353 throw new \RuntimeException(
354 'The command "'.$command."\" generates some errors: \n\n" 354 'The command "' . $command . "\" generates some errors: \n\n"
355 .$output->fetch()); 355 . $output->fetch());
356 } 356 }
357 357
358 return $this; 358 return $this;
@@ -396,7 +396,7 @@ class InstallCommand extends ContainerAwareCommand
396 } 396 }
397 397
398 try { 398 try {
399 return in_array($databaseName, $schemaManager->listDatabases()); 399 return in_array($databaseName, $schemaManager->listDatabases(), true);
400 } catch (\Doctrine\DBAL\Exception\DriverException $e) { 400 } catch (\Doctrine\DBAL\Exception\DriverException $e) {
401 // it means we weren't able to get database list, assume the database doesn't exist 401 // it means we weren't able to get database list, assume the database doesn't exist
402 402
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index d4170d39..7e39992d 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -10,8 +10,8 @@ use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; 10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
11use Wallabag\CoreBundle\Entity\Config; 11use Wallabag\CoreBundle\Entity\Config;
12use Wallabag\CoreBundle\Entity\TaggingRule; 12use Wallabag\CoreBundle\Entity\TaggingRule;
13use Wallabag\CoreBundle\Form\Type\ConfigType;
14use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 13use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
14use Wallabag\CoreBundle\Form\Type\ConfigType;
15use Wallabag\CoreBundle\Form\Type\RssType; 15use Wallabag\CoreBundle\Form\Type\RssType;
16use Wallabag\CoreBundle\Form\Type\TaggingRuleType; 16use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
17use Wallabag\CoreBundle\Form\Type\UserInformationType; 17use Wallabag\CoreBundle\Form\Type\UserInformationType;
@@ -54,7 +54,7 @@ class ConfigController extends Controller
54 } 54 }
55 55
56 // handle changing password 56 // handle changing password
57 $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']); 57 $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config') . '#set4']);
58 $pwdForm->handleRequest($request); 58 $pwdForm->handleRequest($request);
59 59
60 if ($pwdForm->isSubmitted() && $pwdForm->isValid()) { 60 if ($pwdForm->isSubmitted() && $pwdForm->isValid()) {
@@ -69,13 +69,13 @@ class ConfigController extends Controller
69 69
70 $this->get('session')->getFlashBag()->add('notice', $message); 70 $this->get('session')->getFlashBag()->add('notice', $message);
71 71
72 return $this->redirect($this->generateUrl('config').'#set4'); 72 return $this->redirect($this->generateUrl('config') . '#set4');
73 } 73 }
74 74
75 // handle changing user information 75 // handle changing user information
76 $userForm = $this->createForm(UserInformationType::class, $user, [ 76 $userForm = $this->createForm(UserInformationType::class, $user, [
77 'validation_groups' => ['Profile'], 77 'validation_groups' => ['Profile'],
78 'action' => $this->generateUrl('config').'#set3', 78 'action' => $this->generateUrl('config') . '#set3',
79 ]); 79 ]);
80 $userForm->handleRequest($request); 80 $userForm->handleRequest($request);
81 81
@@ -87,11 +87,11 @@ class ConfigController extends Controller
87 'flashes.config.notice.user_updated' 87 'flashes.config.notice.user_updated'
88 ); 88 );
89 89
90 return $this->redirect($this->generateUrl('config').'#set3'); 90 return $this->redirect($this->generateUrl('config') . '#set3');
91 } 91 }
92 92
93 // handle rss information 93 // handle rss information
94 $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']); 94 $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config') . '#set2']);
95 $rssForm->handleRequest($request); 95 $rssForm->handleRequest($request);
96 96
97 if ($rssForm->isSubmitted() && $rssForm->isValid()) { 97 if ($rssForm->isSubmitted() && $rssForm->isValid()) {
@@ -103,12 +103,12 @@ class ConfigController extends Controller
103 'flashes.config.notice.rss_updated' 103 'flashes.config.notice.rss_updated'
104 ); 104 );
105 105
106 return $this->redirect($this->generateUrl('config').'#set2'); 106 return $this->redirect($this->generateUrl('config') . '#set2');
107 } 107 }
108 108
109 // handle tagging rule 109 // handle tagging rule
110 $taggingRule = new TaggingRule(); 110 $taggingRule = new TaggingRule();
111 $action = $this->generateUrl('config').'#set5'; 111 $action = $this->generateUrl('config') . '#set5';
112 112
113 if ($request->query->has('tagging-rule')) { 113 if ($request->query->has('tagging-rule')) {
114 $taggingRule = $this->getDoctrine() 114 $taggingRule = $this->getDoctrine()
@@ -119,7 +119,7 @@ class ConfigController extends Controller
119 return $this->redirect($action); 119 return $this->redirect($action);
120 } 120 }
121 121
122 $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5'; 122 $action = $this->generateUrl('config') . '?tagging-rule=' . $taggingRule->getId() . '#set5';
123 } 123 }
124 124
125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]); 125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
@@ -135,7 +135,7 @@ class ConfigController extends Controller
135 'flashes.config.notice.tagging_rules_updated' 135 'flashes.config.notice.tagging_rules_updated'
136 ); 136 );
137 137
138 return $this->redirect($this->generateUrl('config').'#set5'); 138 return $this->redirect($this->generateUrl('config') . '#set5');
139 } 139 }
140 140
141 return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 141 return $this->render('WallabagCoreBundle:Config:index.html.twig', [
@@ -182,7 +182,7 @@ class ConfigController extends Controller
182 'flashes.config.notice.rss_token_updated' 182 'flashes.config.notice.rss_token_updated'
183 ); 183 );
184 184
185 return $this->redirect($this->generateUrl('config').'#set2'); 185 return $this->redirect($this->generateUrl('config') . '#set2');
186 } 186 }
187 187
188 /** 188 /**
@@ -207,7 +207,7 @@ class ConfigController extends Controller
207 'flashes.config.notice.tagging_rules_deleted' 207 'flashes.config.notice.tagging_rules_deleted'
208 ); 208 );
209 209
210 return $this->redirect($this->generateUrl('config').'#set5'); 210 return $this->redirect($this->generateUrl('config') . '#set5');
211 } 211 }
212 212
213 /** 213 /**
@@ -223,7 +223,7 @@ class ConfigController extends Controller
223 { 223 {
224 $this->validateRuleAction($rule); 224 $this->validateRuleAction($rule);
225 225
226 return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5'); 226 return $this->redirect($this->generateUrl('config') . '?tagging-rule=' . $rule->getId() . '#set5');
227 } 227 }
228 228
229 /** 229 /**
@@ -241,11 +241,9 @@ class ConfigController extends Controller
241 ->getRepository('WallabagAnnotationBundle:Annotation') 241 ->getRepository('WallabagAnnotationBundle:Annotation')
242 ->removeAllByUserId($this->getUser()->getId()); 242 ->removeAllByUserId($this->getUser()->getId());
243 break; 243 break;
244
245 case 'tags': 244 case 'tags':
246 $this->removeAllTagsByUserId($this->getUser()->getId()); 245 $this->removeAllTagsByUserId($this->getUser()->getId());
247 break; 246 break;
248
249 case 'entries': 247 case 'entries':
250 // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff 248 // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
251 // otherwise they won't be removed ... 249 // otherwise they won't be removed ...
@@ -272,10 +270,63 @@ class ConfigController extends Controller
272 270
273 $this->get('session')->getFlashBag()->add( 271 $this->get('session')->getFlashBag()->add(
274 'notice', 272 'notice',
275 'flashes.config.notice.'.$type.'_reset' 273 'flashes.config.notice.' . $type . '_reset'
276 ); 274 );
277 275
278 return $this->redirect($this->generateUrl('config').'#set3'); 276 return $this->redirect($this->generateUrl('config') . '#set3');
277 }
278
279 /**
280 * Delete account for current user.
281 *
282 * @Route("/account/delete", name="delete_account")
283 *
284 * @param Request $request
285 *
286 * @throws AccessDeniedHttpException
287 *
288 * @return \Symfony\Component\HttpFoundation\RedirectResponse
289 */
290 public function deleteAccountAction(Request $request)
291 {
292 $enabledUsers = $this->get('wallabag_user.user_repository')
293 ->getSumEnabledUsers();
294
295 if ($enabledUsers <= 1) {
296 throw new AccessDeniedHttpException();
297 }
298
299 $user = $this->getUser();
300
301 // logout current user
302 $this->get('security.token_storage')->setToken(null);
303 $request->getSession()->invalidate();
304
305 $em = $this->get('fos_user.user_manager');
306 $em->deleteUser($user);
307
308 return $this->redirect($this->generateUrl('fos_user_security_login'));
309 }
310
311 /**
312 * Switch view mode for current user.
313 *
314 * @Route("/config/view-mode", name="switch_view_mode")
315 *
316 * @param Request $request
317 *
318 * @return \Symfony\Component\HttpFoundation\RedirectResponse
319 */
320 public function changeViewModeAction(Request $request)
321 {
322 $user = $this->getUser();
323 $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
324
325 $em = $this->getDoctrine()->getManager();
326 $em->persist($user);
327 $em->flush();
328
329 return $this->redirect($request->headers->get('referer'));
279 } 330 }
280 331
281 /** 332 /**
@@ -349,7 +400,7 @@ class ConfigController extends Controller
349 */ 400 */
350 private function validateRuleAction(TaggingRule $rule) 401 private function validateRuleAction(TaggingRule $rule)
351 { 402 {
352 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { 403 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
353 throw $this->createAccessDeniedException('You can not access this tagging rule.'); 404 throw $this->createAccessDeniedException('You can not access this tagging rule.');
354 } 405 }
355 } 406 }
@@ -373,57 +424,4 @@ class ConfigController extends Controller
373 424
374 return $config; 425 return $config;
375 } 426 }
376
377 /**
378 * Delete account for current user.
379 *
380 * @Route("/account/delete", name="delete_account")
381 *
382 * @param Request $request
383 *
384 * @throws AccessDeniedHttpException
385 *
386 * @return \Symfony\Component\HttpFoundation\RedirectResponse
387 */
388 public function deleteAccountAction(Request $request)
389 {
390 $enabledUsers = $this->get('wallabag_user.user_repository')
391 ->getSumEnabledUsers();
392
393 if ($enabledUsers <= 1) {
394 throw new AccessDeniedHttpException();
395 }
396
397 $user = $this->getUser();
398
399 // logout current user
400 $this->get('security.token_storage')->setToken(null);
401 $request->getSession()->invalidate();
402
403 $em = $this->get('fos_user.user_manager');
404 $em->deleteUser($user);
405
406 return $this->redirect($this->generateUrl('fos_user_security_login'));
407 }
408
409 /**
410 * Switch view mode for current user.
411 *
412 * @Route("/config/view-mode", name="switch_view_mode")
413 *
414 * @param Request $request
415 *
416 * @return \Symfony\Component\HttpFoundation\RedirectResponse
417 */
418 public function changeViewModeAction(Request $request)
419 {
420 $user = $this->getUser();
421 $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
422
423 $em = $this->getDoctrine()->getManager();
424 $em->persist($user);
425 $em->flush();
426
427 return $this->redirect($request->headers->get('referer'));
428 }
429} 427}
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fafa49f1..845ebef6 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -4,17 +4,17 @@ namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\DoctrineORMAdapter; 5use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 11use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Form\Type\EntryFilterType; 13use Wallabag\CoreBundle\Event\EntryDeletedEvent;
14use Wallabag\CoreBundle\Event\EntrySavedEvent;
13use Wallabag\CoreBundle\Form\Type\EditEntryType; 15use Wallabag\CoreBundle\Form\Type\EditEntryType;
16use Wallabag\CoreBundle\Form\Type\EntryFilterType;
14use Wallabag\CoreBundle\Form\Type\NewEntryType; 17use Wallabag\CoreBundle\Form\Type\NewEntryType;
15use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
16use Wallabag\CoreBundle\Event\EntrySavedEvent;
17use Wallabag\CoreBundle\Event\EntryDeletedEvent;
18use Wallabag\CoreBundle\Form\Type\SearchEntryType; 18use Wallabag\CoreBundle\Form\Type\SearchEntryType;
19 19
20class EntryController extends Controller 20class EntryController extends Controller
@@ -52,31 +52,6 @@ class EntryController extends Controller
52 } 52 }
53 53
54 /** 54 /**
55 * Fetch content and update entry.
56 * In case it fails, $entry->getContent will return an error message.
57 *
58 * @param Entry $entry
59 * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
60 */
61 private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
62 {
63 $message = 'flashes.entry.notice.'.$prefixMessage;
64
65 try {
66 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
67 } catch (\Exception $e) {
68 $this->get('logger')->error('Error while saving an entry', [
69 'exception' => $e,
70 'entry' => $entry,
71 ]);
72
73 $message = 'flashes.entry.notice.'.$prefixMessage.'_failed';
74 }
75
76 $this->get('session')->getFlashBag()->add('notice', $message);
77 }
78
79 /**
80 * @param Request $request 55 * @param Request $request
81 * 56 *
82 * @Route("/new-entry", name="new_entry") 57 * @Route("/new-entry", name="new_entry")
@@ -220,7 +195,7 @@ class EntryController extends Controller
220 public function showUnreadAction(Request $request, $page) 195 public function showUnreadAction(Request $request, $page)
221 { 196 {
222 // load the quickstart if no entry in database 197 // load the quickstart if no entry in database
223 if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) == 0) { 198 if ((int) $page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
224 return $this->redirect($this->generateUrl('quickstart')); 199 return $this->redirect($this->generateUrl('quickstart'));
225 } 200 }
226 201
@@ -258,83 +233,6 @@ class EntryController extends Controller
258 } 233 }
259 234
260 /** 235 /**
261 * Global method to retrieve entries depending on the given type
262 * It returns the response to be send.
263 *
264 * @param string $type Entries type: unread, starred or archive
265 * @param Request $request
266 * @param int $page
267 *
268 * @return \Symfony\Component\HttpFoundation\Response
269 */
270 private function showEntries($type, Request $request, $page)
271 {
272 $repository = $this->get('wallabag_core.entry_repository');
273 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
274 $currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : '');
275
276 switch ($type) {
277 case 'search':
278 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
279
280 break;
281 case 'untagged':
282 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
283
284 break;
285 case 'starred':
286 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
287 break;
288
289 case 'archive':
290 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
291 break;
292
293 case 'unread':
294 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
295 break;
296
297 case 'all':
298 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
299 break;
300
301 default:
302 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
303 }
304
305 $form = $this->createForm(EntryFilterType::class);
306
307 if ($request->query->has($form->getName())) {
308 // manually bind values from the request
309 $form->submit($request->query->get($form->getName()));
310
311 // build the query from the given form object
312 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
313 }
314
315 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
316
317 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
318
319 try {
320 $entries->setCurrentPage($page);
321 } catch (OutOfRangeCurrentPageException $e) {
322 if ($page > 1) {
323 return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
324 }
325 }
326
327 return $this->render(
328 'WallabagCoreBundle:Entry:entries.html.twig', [
329 'form' => $form->createView(),
330 'entries' => $entries,
331 'currentPage' => $page,
332 'searchTerm' => $searchTerm,
333 ]
334 );
335 }
336
337 /**
338 * Shows entry content. 236 * Shows entry content.
339 * 237 *
340 * @param Entry $entry 238 * @param Entry $entry
@@ -487,7 +385,7 @@ class EntryController extends Controller
487 385
488 // don't redirect user to the deleted entry (check that the referer doesn't end with the same url) 386 // don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
489 $referer = $request->headers->get('referer'); 387 $referer = $request->headers->get('referer');
490 $to = (1 !== preg_match('#'.$url.'$#i', $referer) ? $referer : null); 388 $to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
491 389
492 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to); 390 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to);
493 391
@@ -495,30 +393,6 @@ class EntryController extends Controller
495 } 393 }
496 394
497 /** 395 /**
498 * Check if the logged user can manage the given entry.
499 *
500 * @param Entry $entry
501 */
502 private function checkUserAction(Entry $entry)
503 {
504 if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
505 throw $this->createAccessDeniedException('You can not access this entry.');
506 }
507 }
508
509 /**
510 * Check for existing entry, if it exists, redirect to it with a message.
511 *
512 * @param Entry $entry
513 *
514 * @return Entry|bool
515 */
516 private function checkIfEntryAlreadyExists(Entry $entry)
517 {
518 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
519 }
520
521 /**
522 * Get public URL for entry (and generate it if necessary). 396 * Get public URL for entry (and generate it if necessary).
523 * 397 *
524 * @param Entry $entry 398 * @param Entry $entry
@@ -604,4 +478,126 @@ class EntryController extends Controller
604 { 478 {
605 return $this->showEntries('untagged', $request, $page); 479 return $this->showEntries('untagged', $request, $page);
606 } 480 }
481
482 /**
483 * Fetch content and update entry.
484 * In case it fails, $entry->getContent will return an error message.
485 *
486 * @param Entry $entry
487 * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
488 */
489 private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
490 {
491 $message = 'flashes.entry.notice.' . $prefixMessage;
492
493 try {
494 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
495 } catch (\Exception $e) {
496 $this->get('logger')->error('Error while saving an entry', [
497 'exception' => $e,
498 'entry' => $entry,
499 ]);
500
501 $message = 'flashes.entry.notice.' . $prefixMessage . '_failed';
502 }
503
504 $this->get('session')->getFlashBag()->add('notice', $message);
505 }
506
507 /**
508 * Global method to retrieve entries depending on the given type
509 * It returns the response to be send.
510 *
511 * @param string $type Entries type: unread, starred or archive
512 * @param Request $request
513 * @param int $page
514 *
515 * @return \Symfony\Component\HttpFoundation\Response
516 */
517 private function showEntries($type, Request $request, $page)
518 {
519 $repository = $this->get('wallabag_core.entry_repository');
520 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
521 $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
522
523 switch ($type) {
524 case 'search':
525 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
526
527 break;
528 case 'untagged':
529 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
530
531 break;
532 case 'starred':
533 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
534 break;
535 case 'archive':
536 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
537 break;
538 case 'unread':
539 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
540 break;
541 case 'all':
542 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
543 break;
544 default:
545 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
546 }
547
548 $form = $this->createForm(EntryFilterType::class);
549
550 if ($request->query->has($form->getName())) {
551 // manually bind values from the request
552 $form->submit($request->query->get($form->getName()));
553
554 // build the query from the given form object
555 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
556 }
557
558 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
559
560 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
561
562 try {
563 $entries->setCurrentPage($page);
564 } catch (OutOfRangeCurrentPageException $e) {
565 if ($page > 1) {
566 return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
567 }
568 }
569
570 return $this->render(
571 'WallabagCoreBundle:Entry:entries.html.twig', [
572 'form' => $form->createView(),
573 'entries' => $entries,
574 'currentPage' => $page,
575 'searchTerm' => $searchTerm,
576 ]
577 );
578 }
579
580 /**
581 * Check if the logged user can manage the given entry.
582 *
583 * @param Entry $entry
584 */
585 private function checkUserAction(Entry $entry)
586 {
587 if (null === $this->getUser() || $this->getUser()->getId() !== $entry->getUser()->getId()) {
588 throw $this->createAccessDeniedException('You can not access this entry.');
589 }
590 }
591
592 /**
593 * Check for existing entry, if it exists, redirect to it with a message.
594 *
595 * @param Entry $entry
596 *
597 * @return Entry|bool
598 */
599 private function checkIfEntryAlreadyExists(Entry $entry)
600 {
601 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
602 }
607} 603}
diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
index abfa9c2f..461309ea 100644
--- a/src/Wallabag/CoreBundle/Controller/ExceptionController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
@@ -14,7 +14,7 @@ class ExceptionController extends BaseExceptionController
14 protected function findTemplate(Request $request, $format, $code, $showException) 14 protected function findTemplate(Request $request, $format, $code, $showException)
15 { 15 {
16 $name = $showException ? 'exception' : 'error'; 16 $name = $showException ? 'exception' : 'error';
17 if ($showException && 'html' == $format) { 17 if ($showException && 'html' === $format) {
18 $name = 'exception_full'; 18 $name = 'exception_full';
19 } 19 }
20 20
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index fda04cfb..6fad122e 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -55,10 +55,10 @@ class ExportController extends Controller
55 public function downloadEntriesAction(Request $request, $format, $category) 55 public function downloadEntriesAction(Request $request, $format, $category)
56 { 56 {
57 $method = ucfirst($category); 57 $method = ucfirst($category);
58 $methodBuilder = 'getBuilderFor'.$method.'ByUser'; 58 $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
59 $repository = $this->get('wallabag_core.entry_repository'); 59 $repository = $this->get('wallabag_core.entry_repository');
60 60
61 if ($category == 'tag_entries') { 61 if ($category === 'tag_entries') {
62 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag')); 62 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
63 63
64 $entries = $repository->findAllByTagId( 64 $entries = $repository->findAllByTagId(
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index e87dd9a1..e84044b1 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -2,19 +2,19 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Adapter\ArrayAdapter; 5use Pagerfanta\Adapter\ArrayAdapter;
6use Pagerfanta\Adapter\DoctrineORMAdapter;
7use Pagerfanta\Exception\OutOfRangeCurrentPageException; 7use Pagerfanta\Exception\OutOfRangeCurrentPageException;
8use Pagerfanta\Pagerfanta; 8use Pagerfanta\Pagerfanta;
9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11use Symfony\Component\HttpFoundation\Request; 12use Symfony\Component\HttpFoundation\Request;
12use Symfony\Component\HttpFoundation\Response; 13use Symfony\Component\HttpFoundation\Response;
13use Symfony\Bundle\FrameworkBundle\Controller\Controller; 14use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
14use Wallabag\CoreBundle\Entity\Entry; 15use Wallabag\CoreBundle\Entity\Entry;
15use Wallabag\CoreBundle\Entity\Tag; 16use Wallabag\CoreBundle\Entity\Tag;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18 18
19class RssController extends Controller 19class RssController extends Controller
20{ 20{
@@ -113,7 +113,7 @@ class RssController extends Controller
113 $entries->setCurrentPage($page); 113 $entries->setCurrentPage($page);
114 } catch (OutOfRangeCurrentPageException $e) { 114 } catch (OutOfRangeCurrentPageException $e) {
115 if ($page > 1) { 115 if ($page > 1) {
116 return $this->redirect($url.'?page='.$entries->getNbPages(), 302); 116 return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
117 } 117 }
118 } 118 }
119 119
@@ -121,7 +121,7 @@ class RssController extends Controller
121 '@WallabagCore/themes/common/Entry/entries.xml.twig', 121 '@WallabagCore/themes/common/Entry/entries.xml.twig',
122 [ 122 [
123 'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), 123 'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
124 'type' => 'tag ('.$tag->getLabel().')', 124 'type' => 'tag (' . $tag->getLabel() . ')',
125 'url' => $url, 125 'url' => $url,
126 'entries' => $entries, 126 'entries' => $entries,
127 ], 127 ],
@@ -147,19 +147,15 @@ class RssController extends Controller
147 case 'starred': 147 case 'starred':
148 $qb = $repository->getBuilderForStarredByUser($user->getId()); 148 $qb = $repository->getBuilderForStarredByUser($user->getId());
149 break; 149 break;
150
151 case 'archive': 150 case 'archive':
152 $qb = $repository->getBuilderForArchiveByUser($user->getId()); 151 $qb = $repository->getBuilderForArchiveByUser($user->getId());
153 break; 152 break;
154
155 case 'unread': 153 case 'unread':
156 $qb = $repository->getBuilderForUnreadByUser($user->getId()); 154 $qb = $repository->getBuilderForUnreadByUser($user->getId());
157 break; 155 break;
158
159 case 'all': 156 case 'all':
160 $qb = $repository->getBuilderForAllByUser($user->getId()); 157 $qb = $repository->getBuilderForAllByUser($user->getId());
161 break; 158 break;
162
163 default: 159 default:
164 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 160 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
165 } 161 }
@@ -171,7 +167,7 @@ class RssController extends Controller
171 $entries->setMaxPerPage($perPage); 167 $entries->setMaxPerPage($perPage);
172 168
173 $url = $this->generateUrl( 169 $url = $this->generateUrl(
174 $type.'_rss', 170 $type . '_rss',
175 [ 171 [
176 'username' => $user->getUsername(), 172 'username' => $user->getUsername(),
177 'token' => $user->getConfig()->getRssToken(), 173 'token' => $user->getConfig()->getRssToken(),
@@ -183,7 +179,7 @@ class RssController extends Controller
183 $entries->setCurrentPage((int) $page); 179 $entries->setCurrentPage((int) $page);
184 } catch (OutOfRangeCurrentPageException $e) { 180 } catch (OutOfRangeCurrentPageException $e) {
185 if ($page > 1) { 181 if ($page > 1) {
186 return $this->redirect($url.'?page='.$entries->getNbPages(), 302); 182 return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
187 } 183 }
188 } 184 }
189 185
diff --git a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
index 98781dab..fa2066dc 100644
--- a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
+++ b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
@@ -2,12 +2,12 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9use Wallabag\UserBundle\Entity\User; 7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Entity\SiteCredential; 9use Wallabag\CoreBundle\Entity\SiteCredential;
10use Wallabag\UserBundle\Entity\User;
11 11
12/** 12/**
13 * SiteCredential controller. 13 * SiteCredential controller.
@@ -167,7 +167,7 @@ class SiteCredentialController extends Controller
167 */ 167 */
168 private function checkUserAction(SiteCredential $siteCredential) 168 private function checkUserAction(SiteCredential $siteCredential)
169 { 169 {
170 if (null === $this->getUser() || $this->getUser()->getId() != $siteCredential->getUser()->getId()) { 170 if (null === $this->getUser() || $this->getUser()->getId() !== $siteCredential->getUser()->getId()) {
171 throw $this->createAccessDeniedException('You can not access this site credential.'); 171 throw $this->createAccessDeniedException('You can not access this site credential.');
172 } 172 }
173 } 173 }
diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php
index 82714217..318af303 100644
--- a/src/Wallabag/CoreBundle/Controller/StaticController.php
+++ b/src/Wallabag/CoreBundle/Controller/StaticController.php
@@ -16,7 +16,9 @@ class StaticController extends Controller
16 16
17 return $this->render( 17 return $this->render(
18 '@WallabagCore/themes/common/Static/howto.html.twig', 18 '@WallabagCore/themes/common/Static/howto.html.twig',
19 ['addonsUrl' => $addonsUrl] 19 [
20 'addonsUrl' => $addonsUrl,
21 ]
20 ); 22 );
21 } 23 }
22 24
@@ -40,8 +42,7 @@ class StaticController extends Controller
40 public function quickstartAction() 42 public function quickstartAction()
41 { 43 {
42 return $this->render( 44 return $this->render(
43 '@WallabagCore/themes/common/Static/quickstart.html.twig', 45 '@WallabagCore/themes/common/Static/quickstart.html.twig'
44 []
45 ); 46 );
46 } 47 }
47} 48}
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index a8b1eadd..f2ca58c6 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -4,13 +4,13 @@ namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\ArrayAdapter; 5use Pagerfanta\Adapter\ArrayAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\CoreBundle\Entity\Tag; 12use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Form\Type\NewTagType; 13use Wallabag\CoreBundle\Form\Type\NewTagType;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
14 14
15class TagController extends Controller 15class TagController extends Controller
16{ 16{
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
index a52288e6..3fe88e7f 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\DataFixtures\ORM; 3namespace Wallabag\CoreBundle\DataFixtures\ORM;
4 4
5use Craue\ConfigBundle\Entity\Setting;
5use Doctrine\Common\DataFixtures\AbstractFixture; 6use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface; 7use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager; 8use Doctrine\Common\Persistence\ObjectManager;
8use Craue\ConfigBundle\Entity\Setting;
9use Symfony\Component\DependencyInjection\ContainerAwareInterface; 9use Symfony\Component\DependencyInjection\ContainerAwareInterface;
10use Symfony\Component\DependencyInjection\ContainerInterface; 10use Symfony\Component\DependencyInjection\ContainerInterface;
11 11
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
index 532ce238..a3ef2b53 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
@@ -31,7 +31,7 @@ class WallabagCoreExtension extends Extension
31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); 31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']);
32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']); 32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']);
33 33
34 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 34 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
35 $loader->load('services.yml'); 35 $loader->load('services.yml');
36 $loader->load('parameters.yml'); 36 $loader->load('parameters.yml');
37 } 37 }
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a0503c39..581e8906 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -5,14 +5,14 @@ namespace Wallabag\CoreBundle\Entity;
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Hateoas\Configuration\Annotation as Hateoas; 7use Hateoas\Configuration\Annotation as Hateoas;
8use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\XmlRoot;
10use JMS\Serializer\Annotation\Exclude; 8use JMS\Serializer\Annotation\Exclude;
11use JMS\Serializer\Annotation\VirtualProperty; 9use JMS\Serializer\Annotation\Groups;
12use JMS\Serializer\Annotation\SerializedName; 10use JMS\Serializer\Annotation\SerializedName;
11use JMS\Serializer\Annotation\VirtualProperty;
12use JMS\Serializer\Annotation\XmlRoot;
13use Symfony\Component\Validator\Constraints as Assert; 13use Symfony\Component\Validator\Constraints as Assert;
14use Wallabag\UserBundle\Entity\User;
15use Wallabag\AnnotationBundle\Entity\Annotation; 14use Wallabag\AnnotationBundle\Entity\Annotation;
15use Wallabag\UserBundle\Entity\User;
16 16
17/** 17/**
18 * Entry. 18 * Entry.
@@ -478,7 +478,7 @@ class Entry
478 */ 478 */
479 public function timestamps() 479 public function timestamps()
480 { 480 {
481 if (is_null($this->createdAt)) { 481 if (null === $this->createdAt) {
482 $this->createdAt = new \DateTime(); 482 $this->createdAt = new \DateTime();
483 } 483 }
484 484
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
index 58075e92..380f820d 100644
--- a/src/Wallabag/CoreBundle/Entity/SiteCredential.php
+++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
@@ -188,7 +188,7 @@ class SiteCredential
188 */ 188 */
189 public function timestamps() 189 public function timestamps()
190 { 190 {
191 if (is_null($this->createdAt)) { 191 if (null === $this->createdAt) {
192 $this->createdAt = new \DateTime(); 192 $this->createdAt = new \DateTime();
193 } 193 }
194 } 194 }
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 4b480ff1..c19023af 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Gedmo\Mapping\Annotation as Gedmo;
7use JMS\Serializer\Annotation\ExclusionPolicy; 8use JMS\Serializer\Annotation\ExclusionPolicy;
8use JMS\Serializer\Annotation\Expose; 9use JMS\Serializer\Annotation\Expose;
9use Gedmo\Mapping\Annotation as Gedmo;
10use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
11 11
12/** 12/**
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
index 4ebe837b..1dd0a1a4 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\CoreBundle\Event\Subscriber; 3namespace Wallabag\CoreBundle\Event\Subscriber;
4 4
5use Symfony\Component\EventDispatcher\EventSubscriberInterface; 5use Doctrine\ORM\EntityManager;
6use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
7use Wallabag\CoreBundle\Helper\DownloadImages; 7use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Event\EntrySavedEvent;
10use Wallabag\CoreBundle\Event\EntryDeletedEvent; 9use Wallabag\CoreBundle\Event\EntryDeletedEvent;
11use Doctrine\ORM\EntityManager; 10use Wallabag\CoreBundle\Event\EntrySavedEvent;
11use Wallabag\CoreBundle\Helper\DownloadImages;
12 12
13class DownloadImagesSubscriber implements EventSubscriberInterface 13class DownloadImagesSubscriber implements EventSubscriberInterface
14{ 14{
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
index 5e6af8cc..9c1d8a1d 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\Event\Subscriber; 3namespace Wallabag\CoreBundle\Event\Subscriber;
4 4
5use Doctrine\Bundle\DoctrineBundle\Registry;
5use Doctrine\Common\EventSubscriber; 6use Doctrine\Common\EventSubscriber;
6use Doctrine\ORM\Event\LifecycleEventArgs; 7use Doctrine\ORM\Event\LifecycleEventArgs;
7use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
8use Doctrine\Bundle\DoctrineBundle\Registry;
9 9
10/** 10/**
11 * SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry. 11 * SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry.
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
index 711c3bf8..35902654 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
@@ -39,12 +39,12 @@ class TablePrefixSubscriber implements EventSubscriber
39 return; 39 return;
40 } 40 }
41 41
42 $classMetadata->setPrimaryTable(['name' => $this->prefix.$classMetadata->getTableName()]); 42 $classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
43 43
44 foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { 44 foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
45 if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { 45 if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
46 $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; 46 $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
47 $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName; 47 $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
48 } 48 }
49 } 49 }
50 } 50 }
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index 6a4c485f..6f8c9e27 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Form\Type;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; 6use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
7use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
9use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
10use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; 7use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
12use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; 8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
9use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
10use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
12use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
13use Symfony\Component\Form\AbstractType; 13use Symfony\Component\Form\AbstractType;
14use Symfony\Component\Form\FormBuilderInterface; 14use Symfony\Component\Form\FormBuilderInterface;
15use Symfony\Component\HttpFoundation\Response; 15use Symfony\Component\HttpFoundation\Response;
@@ -99,7 +99,7 @@ class EntryFilterType extends AbstractType
99 if (strlen($value) <= 2 || empty($value)) { 99 if (strlen($value) <= 2 || empty($value)) {
100 return; 100 return;
101 } 101 }
102 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%'))); 102 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
103 103
104 return $filterQuery->createCondition($expression); 104 return $filterQuery->createCondition($expression);
105 }, 105 },
@@ -113,8 +113,8 @@ class EntryFilterType extends AbstractType
113 } 113 }
114 114
115 $paramName = sprintf('%s', str_replace('.', '_', $field)); 115 $paramName = sprintf('%s', str_replace('.', '_', $field));
116 $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName); 116 $expression = $filterQuery->getExpr()->eq($field, ':' . $paramName);
117 $parameters = array($paramName => $value); 117 $parameters = [$paramName => $value];
118 118
119 return $filterQuery->createCondition($expression, $parameters); 119 return $filterQuery->createCondition($expression, $parameters);
120 }, 120 },
@@ -158,7 +158,7 @@ class EntryFilterType extends AbstractType
158 158
159 // is_public isn't a real field 159 // is_public isn't a real field
160 // we should use the "uid" field to determine if the entry has been made public 160 // we should use the "uid" field to determine if the entry has been made public
161 $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid'); 161 $expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid');
162 162
163 return $filterQuery->createCondition($expression); 163 return $filterQuery->createCondition($expression);
164 }, 164 },
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index a79e6ebe..10689c62 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -6,8 +6,8 @@ use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder; 6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder;
7use Graby\SiteConfig\ConfigBuilder; 7use Graby\SiteConfig\ConfigBuilder;
8use Psr\Log\LoggerInterface; 8use Psr\Log\LoggerInterface;
9use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
10use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
10use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
11 11
12class GrabySiteConfigBuilder implements SiteConfigBuilder 12class GrabySiteConfigBuilder implements SiteConfigBuilder
13{ 13{
@@ -57,7 +57,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
57 { 57 {
58 // required by credentials below 58 // required by credentials below
59 $host = strtolower($host); 59 $host = strtolower($host);
60 if (substr($host, 0, 4) == 'www.') { 60 if (substr($host, 0, 4) === 'www.') {
61 $host = substr($host, 4); 61 $host = substr($host, 4);
62 } 62 }
63 63
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 51bb2ca2..ddecd6f4 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Graby\Graby; 5use Graby\Graby;
6use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Tools\Utils;
9use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; 7use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
10use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; 8use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
11use Symfony\Component\Validator\Constraints\Url as UrlConstraint; 9use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
12use Symfony\Component\Validator\Validator\ValidatorInterface; 10use Symfony\Component\Validator\Validator\ValidatorInterface;
11use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Tools\Utils;
13 13
14/** 14/**
15 * This kind of proxy class take care of getting the content from an url 15 * This kind of proxy class take care of getting the content from an url
@@ -100,7 +100,7 @@ class ContentProxy
100 100
101 // is it a timestamp? 101 // is it a timestamp?
102 if (filter_var($date, FILTER_VALIDATE_INT) !== false) { 102 if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
103 $date = '@'.$content['date']; 103 $date = '@' . $content['date'];
104 } 104 }
105 105
106 try { 106 try {
@@ -189,7 +189,7 @@ class ContentProxy
189 return; 189 return;
190 } 190 }
191 191
192 $this->logger->warning('Language validation failed. '.(string) $errors); 192 $this->logger->warning('Language validation failed. ' . (string) $errors);
193 } 193 }
194 194
195 /** 195 /**
@@ -211,6 +211,6 @@ class ContentProxy
211 return; 211 return;
212 } 212 }
213 213
214 $this->logger->warning('PreviewPicture validation failed. '.(string) $errors); 214 $this->logger->warning('PreviewPicture validation failed. ' . (string) $errors);
215 } 215 }
216} 216}
diff --git a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
index e8b19cb9..7d8c9888 100644
--- a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
6use Defuse\Crypto\Key;
7use Defuse\Crypto\Crypto; 5use Defuse\Crypto\Crypto;
8use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException; 6use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException;
7use Defuse\Crypto\Key;
8use Psr\Log\LoggerInterface;
9 9
10/** 10/**
11 * This is a proxy to crypt and decrypt password used by SiteCredential entity. 11 * This is a proxy to crypt and decrypt password used by SiteCredential entity.
@@ -39,7 +39,7 @@ class CryptoProxy
39 */ 39 */
40 public function crypt($secretValue) 40 public function crypt($secretValue)
41 { 41 {
42 $this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue)); 42 $this->logger->debug('Crypto: crypting value: ' . $this->mask($secretValue));
43 43
44 return Crypto::encrypt($secretValue, $this->loadKey()); 44 return Crypto::encrypt($secretValue, $this->loadKey());
45 } 45 }
@@ -53,12 +53,12 @@ class CryptoProxy
53 */ 53 */
54 public function decrypt($cryptedValue) 54 public function decrypt($cryptedValue)
55 { 55 {
56 $this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue)); 56 $this->logger->debug('Crypto: decrypting value: ' . $this->mask($cryptedValue));
57 57
58 try { 58 try {
59 return Crypto::decrypt($cryptedValue, $this->loadKey()); 59 return Crypto::decrypt($cryptedValue, $this->loadKey());
60 } catch (WrongKeyOrModifiedCiphertextException $e) { 60 } catch (WrongKeyOrModifiedCiphertextException $e) {
61 throw new \RuntimeException('Decrypt fail: '.$e->getMessage()); 61 throw new \RuntimeException('Decrypt fail: ' . $e->getMessage());
62 } 62 }
63 } 63 }
64 64
@@ -81,6 +81,6 @@ class CryptoProxy
81 */ 81 */
82 private function mask($value) 82 private function mask($value)
83 { 83 {
84 return strlen($value) > 0 ? $value[0].'*****'.$value[strlen($value) - 1] : 'Empty value'; 84 return strlen($value) > 0 ? $value[0] . '*****' . $value[strlen($value) - 1] : 'Empty value';
85 } 85 }
86} 86}
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
index 23e98042..9f90ee3e 100644
--- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
+++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
@@ -44,7 +44,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
44 { 44 {
45 $token = $this->tokenStorage->getToken(); 45 $token = $this->tokenStorage->getToken();
46 46
47 if (is_null($token)) { 47 if (null === $token) {
48 return $this->defaultTheme; 48 return $this->defaultTheme;
49 } 49 }
50 50
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index ed888cdb..252ba57c 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -2,12 +2,12 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
6use Symfony\Component\DomCrawler\Crawler;
7use GuzzleHttp\Client; 5use GuzzleHttp\Client;
8use GuzzleHttp\Message\Response; 6use GuzzleHttp\Message\Response;
9use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; 7use Psr\Log\LoggerInterface;
8use Symfony\Component\DomCrawler\Crawler;
10use Symfony\Component\Finder\Finder; 9use Symfony\Component\Finder\Finder;
10use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
11 11
12class DownloadImages 12class DownloadImages
13{ 13{
@@ -31,17 +31,6 @@ class DownloadImages
31 } 31 }
32 32
33 /** 33 /**
34 * Setup base folder where all images are going to be saved.
35 */
36 private function setFolder()
37 {
38 // if folder doesn't exist, attempt to create one and store the folder name in property $folder
39 if (!file_exists($this->baseFolder)) {
40 mkdir($this->baseFolder, 0755, true);
41 }
42 }
43
44 /**
45 * Process the html and extract image from it, save them to local and return the updated html. 34 * Process the html and extract image from it, save them to local and return the updated html.
46 * 35 *
47 * @param int $entryId ID of the entry 36 * @param int $entryId ID of the entry
@@ -97,9 +86,9 @@ class DownloadImages
97 $relativePath = $this->getRelativePath($entryId); 86 $relativePath = $this->getRelativePath($entryId);
98 } 87 }
99 88
100 $this->logger->debug('DownloadImages: working on image: '.$imagePath); 89 $this->logger->debug('DownloadImages: working on image: ' . $imagePath);
101 90
102 $folderPath = $this->baseFolder.'/'.$relativePath; 91 $folderPath = $this->baseFolder . '/' . $relativePath;
103 92
104 // build image path 93 // build image path
105 $absolutePath = $this->getAbsoluteLink($url, $imagePath); 94 $absolutePath = $this->getAbsoluteLink($url, $imagePath);
@@ -123,7 +112,7 @@ class DownloadImages
123 } 112 }
124 113
125 $hashImage = hash('crc32', $absolutePath); 114 $hashImage = hash('crc32', $absolutePath);
126 $localPath = $folderPath.'/'.$hashImage.'.'.$ext; 115 $localPath = $folderPath . '/' . $hashImage . '.' . $ext;
127 116
128 try { 117 try {
129 $im = imagecreatefromstring($res->getBody()); 118 $im = imagecreatefromstring($res->getBody());
@@ -156,7 +145,7 @@ class DownloadImages
156 145
157 imagedestroy($im); 146 imagedestroy($im);
158 147
159 return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext; 148 return $this->wallabagUrl . '/assets/images/' . $relativePath . '/' . $hashImage . '.' . $ext;
160 } 149 }
161 150
162 /** 151 /**
@@ -167,7 +156,7 @@ class DownloadImages
167 public function removeImages($entryId) 156 public function removeImages($entryId)
168 { 157 {
169 $relativePath = $this->getRelativePath($entryId); 158 $relativePath = $this->getRelativePath($entryId);
170 $folderPath = $this->baseFolder.'/'.$relativePath; 159 $folderPath = $this->baseFolder . '/' . $relativePath;
171 160
172 $finder = new Finder(); 161 $finder = new Finder();
173 $finder 162 $finder
@@ -183,6 +172,17 @@ class DownloadImages
183 } 172 }
184 173
185 /** 174 /**
175 * Setup base folder where all images are going to be saved.
176 */
177 private function setFolder()
178 {
179 // if folder doesn't exist, attempt to create one and store the folder name in property $folder
180 if (!file_exists($this->baseFolder)) {
181 mkdir($this->baseFolder, 0755, true);
182 }
183 }
184
185 /**
186 * Generate the folder where we are going to save images based on the entry url. 186 * Generate the folder where we are going to save images based on the entry url.
187 * 187 *
188 * @param int $entryId ID of the entry 188 * @param int $entryId ID of the entry
@@ -192,8 +192,8 @@ class DownloadImages
192 private function getRelativePath($entryId) 192 private function getRelativePath($entryId)
193 { 193 {
194 $hashId = hash('crc32', $entryId); 194 $hashId = hash('crc32', $entryId);
195 $relativePath = $hashId[0].'/'.$hashId[1].'/'.$hashId; 195 $relativePath = $hashId[0] . '/' . $hashId[1] . '/' . $hashId;
196 $folderPath = $this->baseFolder.'/'.$relativePath; 196 $folderPath = $this->baseFolder . '/' . $relativePath;
197 197
198 if (!file_exists($folderPath)) { 198 if (!file_exists($folderPath)) {
199 mkdir($folderPath, 0777, true); 199 mkdir($folderPath, 0777, true);
@@ -270,7 +270,7 @@ class DownloadImages
270 } 270 }
271 271
272 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) { 272 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
273 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: '.$imagePath); 273 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: ' . $imagePath);
274 274
275 return false; 275 return false;
276 } 276 }
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 3d36a4c8..cd74cc4f 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -63,7 +63,7 @@ class EntriesExport
63 */ 63 */
64 public function updateTitle($method) 64 public function updateTitle($method)
65 { 65 {
66 $this->title = $method.' articles'; 66 $this->title = $method . ' articles';
67 67
68 if ('entry' === $method) { 68 if ('entry' === $method) {
69 $this->title = $this->entries[0]->getTitle(); 69 $this->title = $this->entries[0]->getTitle();
@@ -81,7 +81,7 @@ class EntriesExport
81 */ 81 */
82 public function exportAs($format) 82 public function exportAs($format)
83 { 83 {
84 $functionName = 'produce'.ucfirst($format); 84 $functionName = 'produce' . ucfirst($format);
85 if (method_exists($this, $functionName)) { 85 if (method_exists($this, $functionName)) {
86 return $this->$functionName(); 86 return $this->$functionName();
87 } 87 }
@@ -106,12 +106,12 @@ class EntriesExport
106 */ 106 */
107 $content_start = 107 $content_start =
108 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 108 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
109 ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" 109 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
110 .'<head>' 110 . '<head>'
111 ."<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n" 111 . "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
112 ."<title>wallabag articles book</title>\n" 112 . "<title>wallabag articles book</title>\n"
113 ."</head>\n" 113 . "</head>\n"
114 ."<body>\n"; 114 . "<body>\n";
115 115
116 $bookEnd = "</body>\n</html>\n"; 116 $bookEnd = "</body>\n</html>\n";
117 117
@@ -164,11 +164,11 @@ class EntriesExport
164 // in filenames, we limit to A-z/0-9 164 // in filenames, we limit to A-z/0-9
165 $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle()); 165 $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
166 166
167 $chapter = $content_start.$entry->getContent().$bookEnd; 167 $chapter = $content_start . $entry->getContent() . $bookEnd;
168 $book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD); 168 $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
169 } 169 }
170 170
171 $book->addChapter('Notices', 'Cover2.html', $content_start.$this->getExportInformation('PHPePub').$bookEnd); 171 $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd);
172 172
173 return Response::create( 173 return Response::create(
174 $book->getBook(), 174 $book->getBook(),
@@ -176,7 +176,7 @@ class EntriesExport
176 [ 176 [
177 'Content-Description' => 'File Transfer', 177 'Content-Description' => 'File Transfer',
178 'Content-type' => 'application/epub+zip', 178 'Content-type' => 'application/epub+zip',
179 'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"', 179 'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"',
180 'Content-Transfer-Encoding' => 'binary', 180 'Content-Transfer-Encoding' => 'binary',
181 ] 181 ]
182 ); 182 );
@@ -228,7 +228,7 @@ class EntriesExport
228 'Accept-Ranges' => 'bytes', 228 'Accept-Ranges' => 'bytes',
229 'Content-Description' => 'File Transfer', 229 'Content-Description' => 'File Transfer',
230 'Content-type' => 'application/x-mobipocket-ebook', 230 'Content-type' => 'application/x-mobipocket-ebook',
231 'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"', 231 'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"',
232 'Content-Transfer-Encoding' => 'binary', 232 'Content-Transfer-Encoding' => 'binary',
233 ] 233 ]
234 ); 234 );
@@ -256,7 +256,7 @@ class EntriesExport
256 * Front page 256 * Front page
257 */ 257 */
258 $pdf->AddPage(); 258 $pdf->AddPage();
259 $intro = '<h1>'.$this->title.'</h1>'.$this->getExportInformation('tcpdf'); 259 $intro = '<h1>' . $this->title . '</h1>' . $this->getExportInformation('tcpdf');
260 260
261 $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true); 261 $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
262 262
@@ -269,7 +269,7 @@ class EntriesExport
269 } 269 }
270 270
271 $pdf->AddPage(); 271 $pdf->AddPage();
272 $html = '<h1>'.$entry->getTitle().'</h1>'; 272 $html = '<h1>' . $entry->getTitle() . '</h1>';
273 $html .= $entry->getContent(); 273 $html .= $entry->getContent();
274 274
275 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); 275 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
@@ -284,7 +284,7 @@ class EntriesExport
284 [ 284 [
285 'Content-Description' => 'File Transfer', 285 'Content-Description' => 'File Transfer',
286 'Content-type' => 'application/pdf', 286 'Content-type' => 'application/pdf',
287 'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"', 287 'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
288 'Content-Transfer-Encoding' => 'binary', 288 'Content-Transfer-Encoding' => 'binary',
289 ] 289 ]
290 ); 290 );
@@ -330,7 +330,7 @@ class EntriesExport
330 200, 330 200,
331 [ 331 [
332 'Content-type' => 'application/csv', 332 'Content-type' => 'application/csv',
333 'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"', 333 'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
334 'Content-Transfer-Encoding' => 'UTF-8', 334 'Content-Transfer-Encoding' => 'UTF-8',
335 ] 335 ]
336 ); 336 );
@@ -348,7 +348,7 @@ class EntriesExport
348 200, 348 200,
349 [ 349 [
350 'Content-type' => 'application/json', 350 'Content-type' => 'application/json',
351 'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"', 351 'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"',
352 'Content-Transfer-Encoding' => 'UTF-8', 352 'Content-Transfer-Encoding' => 'UTF-8',
353 ] 353 ]
354 ); 354 );
@@ -366,7 +366,7 @@ class EntriesExport
366 200, 366 200,
367 [ 367 [
368 'Content-type' => 'application/xml', 368 'Content-type' => 'application/xml',
369 'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"', 369 'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"',
370 'Content-Transfer-Encoding' => 'UTF-8', 370 'Content-Transfer-Encoding' => 'UTF-8',
371 ] 371 ]
372 ); 372 );
@@ -382,8 +382,8 @@ class EntriesExport
382 $content = ''; 382 $content = '';
383 $bar = str_repeat('=', 100); 383 $bar = str_repeat('=', 100);
384 foreach ($this->entries as $entry) { 384 foreach ($this->entries as $entry) {
385 $content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n"; 385 $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
386 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n"; 386 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n";
387 } 387 }
388 388
389 return Response::create( 389 return Response::create(
@@ -391,7 +391,7 @@ class EntriesExport
391 200, 391 200,
392 [ 392 [
393 'Content-type' => 'text/plain', 393 'Content-type' => 'text/plain',
394 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"', 394 'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"',
395 'Content-Transfer-Encoding' => 'UTF-8', 395 'Content-Transfer-Encoding' => 'UTF-8',
396 ] 396 ]
397 ); 397 );
@@ -427,7 +427,7 @@ class EntriesExport
427 $info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate); 427 $info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate);
428 428
429 if ('tcpdf' === $type) { 429 if ('tcpdf' === $type) {
430 return str_replace('%IMAGE%', '<img src="'.$this->logoPath.'" />', $info); 430 return str_replace('%IMAGE%', '<img src="' . $this->logoPath . '" />', $info);
431 } 431 }
432 432
433 return str_replace('%IMAGE%', '', $info); 433 return str_replace('%IMAGE%', '', $info);
diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
index 43f5b119..4602a684 100644
--- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
+++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
@@ -41,7 +41,7 @@ class HttpClientFactory
41 */ 41 */
42 public function buildHttpClient() 42 public function buildHttpClient()
43 { 43 {
44 $this->logger->log('debug', 'Restricted access config enabled?', array('enabled' => (int) $this->restrictedAccess)); 44 $this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]);
45 45
46 if (0 === (int) $this->restrictedAccess) { 46 if (0 === (int) $this->restrictedAccess) {
47 return; 47 return;
diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
index 231a0b52..49c1ea41 100644
--- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
+++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
@@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Pagerfanta\Adapter\AdapterInterface; 5use Pagerfanta\Adapter\AdapterInterface;
6use Pagerfanta\Pagerfanta; 6use Pagerfanta\Pagerfanta;
7use Wallabag\UserBundle\Entity\User;
8use Symfony\Component\Routing\Router; 7use Symfony\Component\Routing\Router;
9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 8use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9use Wallabag\UserBundle\Entity\User;
10 10
11class PreparePagerForEntries 11class PreparePagerForEntries
12{ 12{
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 509d0dec..63f65067 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
5use RulerZ\RulerZ; 6use RulerZ\RulerZ;
6use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
8use Wallabag\CoreBundle\Repository\EntryRepository; 9use Wallabag\CoreBundle\Repository\EntryRepository;
9use Wallabag\CoreBundle\Repository\TagRepository; 10use Wallabag\CoreBundle\Repository\TagRepository;
10use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11use Psr\Log\LoggerInterface;
12 12
13class RuleBasedTagger 13class RuleBasedTagger
14{ 14{
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 9bda4e15..c27ee90c 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -11,21 +11,6 @@ use Wallabag\CoreBundle\Entity\Tag;
11class EntryRepository extends EntityRepository 11class EntryRepository extends EntityRepository
12{ 12{
13 /** 13 /**
14 * Return a query builder to used by other getBuilderFor* method.
15 *
16 * @param int $userId
17 *
18 * @return QueryBuilder
19 */
20 private function getBuilderByUser($userId)
21 {
22 return $this->createQueryBuilder('e')
23 ->andWhere('e.user = :userId')->setParameter('userId', $userId)
24 ->orderBy('e.createdAt', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all entries for a user. 14 * Retrieves all entries for a user.
30 * 15 *
31 * @param int $userId 16 * @param int $userId
@@ -108,7 +93,7 @@ class EntryRepository extends EntityRepository
108 93
109 // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive 94 // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive
110 $qb 95 $qb
111 ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') 96 ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%')
112 ->leftJoin('e.tags', 't') 97 ->leftJoin('e.tags', 't')
113 ->groupBy('e.id'); 98 ->groupBy('e.id');
114 99
@@ -158,7 +143,7 @@ class EntryRepository extends EntityRepository
158 } 143 }
159 144
160 if (null !== $isPublic) { 145 if (null !== $isPublic) {
161 $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL'); 146 $qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL');
162 } 147 }
163 148
164 if ($since > 0) { 149 if ($since > 0) {
@@ -340,7 +325,7 @@ class EntryRepository extends EntityRepository
340 ->where('e.user=:userId')->setParameter('userId', $userId) 325 ->where('e.user=:userId')->setParameter('userId', $userId)
341 ; 326 ;
342 327
343 return $qb->getQuery()->getSingleScalarResult(); 328 return (int) $qb->getQuery()->getSingleScalarResult();
344 } 329 }
345 330
346 /** 331 /**
@@ -360,7 +345,7 @@ class EntryRepository extends EntityRepository
360 ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) 345 ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
361 ; 346 ;
362 347
363 return $qb->getQuery()->getSingleScalarResult(); 348 return (int) $qb->getQuery()->getSingleScalarResult();
364 } 349 }
365 350
366 /** 351 /**
@@ -414,4 +399,19 @@ class EntryRepository extends EntityRepository
414 ->getQuery() 399 ->getQuery()
415 ->getResult(); 400 ->getResult();
416 } 401 }
402
403 /**
404 * Return a query builder to used by other getBuilderFor* method.
405 *
406 * @param int $userId
407 *
408 * @return QueryBuilder
409 */
410 private function getBuilderByUser($userId)
411 {
412 return $this->createQueryBuilder('e')
413 ->andWhere('e.user = :userId')->setParameter('userId', $userId)
414 ->orderBy('e.createdAt', 'desc')
415 ;
416 }
417} 417}
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index a305c53f..351172c4 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -3,9 +3,9 @@
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
6use Symfony\Component\Translation\TranslatorInterface;
6use Wallabag\CoreBundle\Repository\EntryRepository; 7use Wallabag\CoreBundle\Repository\EntryRepository;
7use Wallabag\CoreBundle\Repository\TagRepository; 8use Wallabag\CoreBundle\Repository\TagRepository;
8use Symfony\Component\Translation\TranslatorInterface;
9 9
10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface 10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
11{ 11{
@@ -33,11 +33,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
33 33
34 public function getFunctions() 34 public function getFunctions()
35 { 35 {
36 return array( 36 return [
37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), 37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']),
38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), 38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']),
39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), 39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']),
40 ); 40 ];
41 } 41 }
42 42
43 public function removeWww($url) 43 public function removeWww($url)
@@ -64,19 +64,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
64 case 'starred': 64 case 'starred':
65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId()); 65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId());
66 break; 66 break;
67
68 case 'archive': 67 case 'archive':
69 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId()); 68 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId());
70 break; 69 break;
71
72 case 'unread': 70 case 'unread':
73 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId()); 71 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId());
74 break; 72 break;
75
76 case 'all': 73 case 'all':
77 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); 74 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
78 break; 75 break;
79
80 default: 76 default:
81 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 77 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
82 } 78 }
@@ -139,7 +135,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
139 $nbDays = (int) $interval->format('%a') ?: 1; 135 $nbDays = (int) $interval->format('%a') ?: 1;
140 136
141 // force setlocale for date translation 137 // force setlocale for date translation
142 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage()))); 138 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()) . '_' . strtoupper(strtolower($user->getConfig()->getLanguage())));
143 139
144 return $this->translator->trans('footer.stats', [ 140 return $this->translator->trans('footer.stats', [
145 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()), 141 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()),
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index 5f1ab0af..99056c2c 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -5,8 +5,8 @@ namespace Wallabag\ImportBundle\Command;
5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6use Symfony\Component\Config\Definition\Exception\Exception; 6use Symfony\Component\Config\Definition\Exception\Exception;
7use Symfony\Component\Console\Input\InputArgument; 7use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputOption;
9use Symfony\Component\Console\Input\InputInterface; 8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface; 10use Symfony\Component\Console\Output\OutputInterface;
11 11
12class ImportCommand extends ContainerAwareCommand 12class ImportCommand extends ContainerAwareCommand
@@ -27,7 +27,7 @@ class ImportCommand extends ContainerAwareCommand
27 27
28 protected function execute(InputInterface $input, OutputInterface $output) 28 protected function execute(InputInterface $input, OutputInterface $output)
29 { 29 {
30 $output->writeln('Start : '.(new \DateTime())->format('d-m-Y G:i:s').' ---'); 30 $output->writeln('Start : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
31 31
32 if (!file_exists($input->getArgument('filepath'))) { 32 if (!file_exists($input->getArgument('filepath'))) {
33 throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath'))); 33 throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath')));
@@ -80,12 +80,12 @@ class ImportCommand extends ContainerAwareCommand
80 80
81 if (true === $res) { 81 if (true === $res) {
82 $summary = $import->getSummary(); 82 $summary = $import->getSummary();
83 $output->writeln('<info>'.$summary['imported'].' imported</info>'); 83 $output->writeln('<info>' . $summary['imported'] . ' imported</info>');
84 $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>'); 84 $output->writeln('<comment>' . $summary['skipped'] . ' already saved</comment>');
85 } 85 }
86 86
87 $em->clear(); 87 $em->clear();
88 88
89 $output->writeln('End : '.(new \DateTime())->format('d-m-Y G:i:s').' ---'); 89 $output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
90 } 90 }
91} 91}
diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
index 2d06af44..d94900ad 100644
--- a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
+++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\ImportBundle\Command; 3namespace Wallabag\ImportBundle\Command;
4 4
5use Simpleue\Worker\QueueWorker;
5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 6use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6use Symfony\Component\Config\Definition\Exception\Exception; 7use Symfony\Component\Config\Definition\Exception\Exception;
7use Symfony\Component\Console\Input\InputArgument; 8use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputOption;
9use Symfony\Component\Console\Input\InputInterface; 9use Symfony\Component\Console\Input\InputInterface;
10use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface; 11use Symfony\Component\Console\Output\OutputInterface;
11use Simpleue\Worker\QueueWorker;
12 12
13class RedisWorkerCommand extends ContainerAwareCommand 13class RedisWorkerCommand extends ContainerAwareCommand
14{ 14{
@@ -24,18 +24,18 @@ class RedisWorkerCommand extends ContainerAwareCommand
24 24
25 protected function execute(InputInterface $input, OutputInterface $output) 25 protected function execute(InputInterface $input, OutputInterface $output)
26 { 26 {
27 $output->writeln('Worker started at: '.(new \DateTime())->format('d-m-Y G:i:s')); 27 $output->writeln('Worker started at: ' . (new \DateTime())->format('d-m-Y G:i:s'));
28 $output->writeln('Waiting for message ...'); 28 $output->writeln('Waiting for message ...');
29 29
30 $serviceName = $input->getArgument('serviceName'); 30 $serviceName = $input->getArgument('serviceName');
31 31
32 if (!$this->getContainer()->has('wallabag_import.queue.redis.'.$serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.'.$serviceName)) { 32 if (!$this->getContainer()->has('wallabag_import.queue.redis.' . $serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.' . $serviceName)) {
33 throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName'))); 33 throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName')));
34 } 34 }
35 35
36 $worker = new QueueWorker( 36 $worker = new QueueWorker(
37 $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), 37 $this->getContainer()->get('wallabag_import.queue.redis.' . $serviceName),
38 $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName), 38 $this->getContainer()->get('wallabag_import.consumer.redis.' . $serviceName),
39 (int) $input->getOption('maxIterations') 39 (int) $input->getOption('maxIterations')
40 ); 40 );
41 41
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
index 992ce1ad..b035f5cc 100644
--- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
+++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
@@ -3,14 +3,14 @@
3namespace Wallabag\ImportBundle\Consumer; 3namespace Wallabag\ImportBundle\Consumer;
4 4
5use Doctrine\ORM\EntityManager; 5use Doctrine\ORM\EntityManager;
6use Wallabag\ImportBundle\Import\AbstractImport;
7use Wallabag\UserBundle\Repository\UserRepository;
8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag;
10use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
11use Psr\Log\NullLogger; 7use Psr\Log\NullLogger;
12use Symfony\Component\EventDispatcher\EventDispatcherInterface; 8use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag;
13use Wallabag\CoreBundle\Event\EntrySavedEvent; 11use Wallabag\CoreBundle\Event\EntrySavedEvent;
12use Wallabag\ImportBundle\Import\AbstractImport;
13use Wallabag\UserBundle\Repository\UserRepository;
14 14
15abstract class AbstractConsumer 15abstract class AbstractConsumer
16{ 16{
@@ -76,7 +76,7 @@ abstract class AbstractConsumer
76 return false; 76 return false;
77 } 77 }
78 78
79 $this->logger->info('Content with url imported! ('.$entry->getUrl().')'); 79 $this->logger->info('Content with url imported! (' . $entry->getUrl() . ')');
80 80
81 return true; 81 return true;
82 } 82 }
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php
index e119098f..0753e318 100644
--- a/src/Wallabag/ImportBundle/Controller/BrowserController.php
+++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Wallabag\ImportBundle\Form\Type\UploadImportType; 9use Wallabag\ImportBundle\Form\Type\UploadImportType;
@@ -11,20 +11,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
11abstract class BrowserController extends Controller 11abstract class BrowserController extends Controller
12{ 12{
13 /** 13 /**
14 * Return the service to handle the import.
15 *
16 * @return \Wallabag\ImportBundle\Import\ImportInterface
17 */
18 abstract protected function getImportService();
19
20 /**
21 * Return the template used for the form.
22 *
23 * @return string
24 */
25 abstract protected function getImportTemplate();
26
27 /**
28 * @Route("/browser", name="import_browser") 14 * @Route("/browser", name="import_browser")
29 * 15 *
30 * @param Request $request 16 * @param Request $request
@@ -42,11 +28,11 @@ abstract class BrowserController extends Controller
42 if ($form->isSubmitted() && $form->isValid()) { 28 if ($form->isSubmitted() && $form->isValid()) {
43 $file = $form->get('file')->getData(); 29 $file = $form->get('file')->getData();
44 $markAsRead = $form->get('mark_as_read')->getData(); 30 $markAsRead = $form->get('mark_as_read')->getData();
45 $name = $this->getUser()->getId().'.json'; 31 $name = $this->getUser()->getId() . '.json';
46 32
47 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 33 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
48 $res = $wallabag 34 $res = $wallabag
49 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 35 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
50 ->setMarkAsRead($markAsRead) 36 ->setMarkAsRead($markAsRead)
51 ->import(); 37 ->import();
52 38
@@ -65,7 +51,7 @@ abstract class BrowserController extends Controller
65 ]); 51 ]);
66 } 52 }
67 53
68 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 54 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
69 } 55 }
70 56
71 $this->get('session')->getFlashBag()->add( 57 $this->get('session')->getFlashBag()->add(
@@ -74,12 +60,11 @@ abstract class BrowserController extends Controller
74 ); 60 );
75 61
76 return $this->redirect($this->generateUrl('homepage')); 62 return $this->redirect($this->generateUrl('homepage'));
77 } else { 63 }
78 $this->get('session')->getFlashBag()->add( 64 $this->get('session')->getFlashBag()->add(
79 'notice', 65 'notice',
80 'flashes.import.notice.failed_on_file' 66 'flashes.import.notice.failed_on_file'
81 ); 67 );
82 }
83 } 68 }
84 69
85 return $this->render($this->getImportTemplate(), [ 70 return $this->render($this->getImportTemplate(), [
@@ -87,4 +72,18 @@ abstract class BrowserController extends Controller
87 'import' => $wallabag, 72 'import' => $wallabag,
88 ]); 73 ]);
89 } 74 }
75
76 /**
77 * Return the service to handle the import.
78 *
79 * @return \Wallabag\ImportBundle\Import\ImportInterface
80 */
81 abstract protected function getImportService();
82
83 /**
84 * Return the template used for the form.
85 *
86 * @return string
87 */
88 abstract protected function getImportTemplate();
90} 89}
diff --git a/src/Wallabag/ImportBundle/Controller/ChromeController.php b/src/Wallabag/ImportBundle/Controller/ChromeController.php
index 454f3347..0cb418a1 100644
--- a/src/Wallabag/ImportBundle/Controller/ChromeController.php
+++ b/src/Wallabag/ImportBundle/Controller/ChromeController.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class ChromeController extends BrowserController 8class ChromeController extends BrowserController
9{ 9{
10 /** 10 /**
11 * @Route("/chrome", name="import_chrome")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class ChromeController extends BrowserController
30 { 38 {
31 return 'WallabagImportBundle:Chrome:index.html.twig'; 39 return 'WallabagImportBundle:Chrome:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/chrome", name="import_chrome")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/FirefoxController.php b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
index c329b9c4..88697f9d 100644
--- a/src/Wallabag/ImportBundle/Controller/FirefoxController.php
+++ b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class FirefoxController extends BrowserController 8class FirefoxController extends BrowserController
9{ 9{
10 /** 10 /**
11 * @Route("/firefox", name="import_firefox")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class FirefoxController extends BrowserController
30 { 38 {
31 return 'WallabagImportBundle:Firefox:index.html.twig'; 39 return 'WallabagImportBundle:Firefox:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/firefox", name="import_firefox")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index 237c748e..7e4fd174 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7 7
8class ImportController extends Controller 8class ImportController extends Controller
9{ 9{
@@ -86,9 +86,9 @@ class ImportController extends Controller
86 private function getTotalMessageInRabbitQueue($importService) 86 private function getTotalMessageInRabbitQueue($importService)
87 { 87 {
88 $message = $this 88 $message = $this
89 ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer') 89 ->get('old_sound_rabbit_mq.import_' . $importService . '_consumer')
90 ->getChannel() 90 ->getChannel()
91 ->basic_get('wallabag.import.'.$importService); 91 ->basic_get('wallabag.import.' . $importService);
92 92
93 if (null === $message) { 93 if (null === $message) {
94 return 0; 94 return 0;
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
index 0251acb9..550679c3 100644
--- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php
+++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class InstapaperController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'instapaper_'.$this->getUser()->getId().'.csv'; 32 $name = 'instapaper_' . $this->getUser()->getId() . '.csv';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $instapaper 35 $res = $instapaper
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class InstapaperController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class InstapaperController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php
index d0ad8aa8..0e57fd41 100644
--- a/src/Wallabag/ImportBundle/Controller/PinboardController.php
+++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class PinboardController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'pinboard_'.$this->getUser()->getId().'.json'; 32 $name = 'pinboard_' . $this->getUser()->getId() . '.json';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $pinboard 35 $res = $pinboard
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class PinboardController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class PinboardController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 56be5cbf..9f28819a 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -2,34 +2,15 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Component\HttpFoundation\Request; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 7use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
10 10
11class PocketController extends Controller 11class PocketController extends Controller
12{ 12{
13 /** 13 /**
14 * Return Pocket Import Service with or without RabbitMQ enabled.
15 *
16 * @return \Wallabag\ImportBundle\Import\PocketImport
17 */
18 private function getPocketImportService()
19 {
20 $pocket = $this->get('wallabag_import.pocket.import');
21 $pocket->setUser($this->getUser());
22
23 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
24 $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
25 } elseif ($this->get('craue_config')->get('import_with_redis')) {
26 $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
27 }
28
29 return $pocket;
30 }
31
32 /**
33 * @Route("/pocket", name="import_pocket") 14 * @Route("/pocket", name="import_pocket")
34 */ 15 */
35 public function indexAction() 16 public function indexAction()
@@ -70,7 +51,7 @@ class PocketController extends Controller
70 $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']); 51 $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
71 52
72 return $this->redirect( 53 return $this->redirect(
73 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), 54 'https://getpocket.com/auth/authorize?request_token=' . $requestToken . '&redirect_uri=' . $this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
74 301 55 301
75 ); 56 );
76 } 57 }
@@ -117,4 +98,23 @@ class PocketController extends Controller
117 98
118 return $this->redirect($this->generateUrl('homepage')); 99 return $this->redirect($this->generateUrl('homepage'));
119 } 100 }
101
102 /**
103 * Return Pocket Import Service with or without RabbitMQ enabled.
104 *
105 * @return \Wallabag\ImportBundle\Import\PocketImport
106 */
107 private function getPocketImportService()
108 {
109 $pocket = $this->get('wallabag_import.pocket.import');
110 $pocket->setUser($this->getUser());
111
112 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
113 $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
114 } elseif ($this->get('craue_config')->get('import_with_redis')) {
115 $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
116 }
117
118 return $pocket;
119 }
120} 120}
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
index aa732ddd..59de24cb 100644
--- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
+++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class ReadabilityController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'readability_'.$this->getUser()->getId().'.json'; 32 $name = 'readability_' . $this->getUser()->getId() . '.json';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $readability 35 $res = $readability
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class ReadabilityController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class ReadabilityController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Readability:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Readability:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php
index e81c1ca9..7b61805b 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagController.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php
@@ -12,20 +12,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
12abstract class WallabagController extends Controller 12abstract class WallabagController extends Controller
13{ 13{
14 /** 14 /**
15 * Return the service to handle the import.
16 *
17 * @return \Wallabag\ImportBundle\Import\ImportInterface
18 */
19 abstract protected function getImportService();
20
21 /**
22 * Return the template used for the form.
23 *
24 * @return string
25 */
26 abstract protected function getImportTemplate();
27
28 /**
29 * Handle import request. 15 * Handle import request.
30 * 16 *
31 * @param Request $request 17 * @param Request $request
@@ -43,11 +29,11 @@ abstract class WallabagController extends Controller
43 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
44 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
45 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
46 $name = $this->getUser()->getId().'.json'; 32 $name = $this->getUser()->getId() . '.json';
47 33
48 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
49 $res = $wallabag 35 $res = $wallabag
50 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
51 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
52 ->import(); 38 ->import();
53 39
@@ -66,7 +52,7 @@ abstract class WallabagController extends Controller
66 ]); 52 ]);
67 } 53 }
68 54
69 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
70 } 56 }
71 57
72 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -75,12 +61,12 @@ abstract class WallabagController extends Controller
75 ); 61 );
76 62
77 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
78 } else {
79 $this->get('session')->getFlashBag()->add(
80 'notice',
81 'flashes.import.notice.failed_on_file'
82 );
83 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
84 } 70 }
85 71
86 return $this->render($this->getImportTemplate(), [ 72 return $this->render($this->getImportTemplate(), [
@@ -88,4 +74,18 @@ abstract class WallabagController extends Controller
88 'import' => $wallabag, 74 'import' => $wallabag,
89 ]); 75 ]);
90 } 76 }
77
78 /**
79 * Return the service to handle the import.
80 *
81 * @return \Wallabag\ImportBundle\Import\ImportInterface
82 */
83 abstract protected function getImportService();
84
85 /**
86 * Return the template used for the form.
87 *
88 * @return string
89 */
90 abstract protected function getImportTemplate();
91} 91}
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
index 312c7a35..d700d8a8 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class WallabagV1Controller extends WallabagController 8class WallabagV1Controller extends WallabagController
9{ 9{
10 /** 10 /**
11 * @Route("/wallabag-v1", name="import_wallabag_v1")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class WallabagV1Controller extends WallabagController
30 { 38 {
31 return 'WallabagImportBundle:WallabagV1:index.html.twig'; 39 return 'WallabagImportBundle:WallabagV1:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/wallabag-v1", name="import_wallabag_v1")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
index 45211fe6..ab26400c 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class WallabagV2Controller extends WallabagController 8class WallabagV2Controller extends WallabagController
9{ 9{
10 /** 10 /**
11 * @Route("/wallabag-v2", name="import_wallabag_v2")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class WallabagV2Controller extends WallabagController
30 { 38 {
31 return 'WallabagImportBundle:WallabagV2:index.html.twig'; 39 return 'WallabagImportBundle:WallabagV2:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/wallabag-v2", name="import_wallabag_v2")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php b/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
index 3f23c36b..cab70297 100644
--- a/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
+++ b/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\ImportBundle\DependencyInjection; 3namespace Wallabag\ImportBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\Config\FileLocator; 5use Symfony\Component\Config\FileLocator;
7use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\DependencyInjection\ContainerBuilder;
8use Symfony\Component\DependencyInjection\Loader; 7use Symfony\Component\DependencyInjection\Loader;
8use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9 9
10class WallabagImportExtension extends Extension 10class WallabagImportExtension extends Extension
11{ 11{
@@ -16,7 +16,7 @@ class WallabagImportExtension extends Extension
16 $container->setParameter('wallabag_import.allow_mimetypes', $config['allow_mimetypes']); 16 $container->setParameter('wallabag_import.allow_mimetypes', $config['allow_mimetypes']);
17 $container->setParameter('wallabag_import.resource_dir', $config['resource_dir']); 17 $container->setParameter('wallabag_import.resource_dir', $config['resource_dir']);
18 18
19 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 19 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
20 $loader->load('services.yml'); 20 $loader->load('services.yml');
21 } 21 }
22 22
diff --git a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
index f50424c1..c50ef8c9 100644
--- a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
+++ b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
@@ -3,10 +3,10 @@
3namespace Wallabag\ImportBundle\Form\Type; 3namespace Wallabag\ImportBundle\Form\Type;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\FileType;
9use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7use Symfony\Component\Form\Extension\Core\Type\FileType;
8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9use Symfony\Component\Form\FormBuilderInterface;
10 10
11class UploadImportType extends AbstractType 11class UploadImportType extends AbstractType
12{ 12{
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 9b624296..cb46db09 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -2,17 +2,17 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Doctrine\ORM\EntityManager;
6use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
5use Psr\Log\LoggerInterface; 7use Psr\Log\LoggerInterface;
6use Psr\Log\NullLogger; 8use Psr\Log\NullLogger;
7use Doctrine\ORM\EntityManager; 9use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8use Wallabag\CoreBundle\Helper\ContentProxy;
9use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Event\EntrySavedEvent;
13use Wallabag\CoreBundle\Helper\ContentProxy;
11use Wallabag\CoreBundle\Helper\TagsAssigner; 14use Wallabag\CoreBundle\Helper\TagsAssigner;
12use Wallabag\UserBundle\Entity\User; 15use Wallabag\UserBundle\Entity\User;
13use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
14use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15use Wallabag\CoreBundle\Event\EntrySavedEvent;
16 16
17abstract class AbstractImport implements ImportInterface 17abstract class AbstractImport implements ImportInterface
18{ 18{
@@ -98,6 +98,27 @@ abstract class AbstractImport implements ImportInterface
98 } 98 }
99 99
100 /** 100 /**
101 * {@inheritdoc}
102 */
103 public function getSummary()
104 {
105 return [
106 'skipped' => $this->skippedEntries,
107 'imported' => $this->importedEntries,
108 'queued' => $this->queuedEntries,
109 ];
110 }
111
112 /**
113 * Parse one entry.
114 *
115 * @param array $importedEntry
116 *
117 * @return Entry
118 */
119 abstract public function parseEntry(array $importedEntry);
120
121 /**
101 * Fetch content from the ContentProxy (using graby). 122 * Fetch content from the ContentProxy (using graby).
102 * If it fails return the given entry to be saved in all case (to avoid user to loose the content). 123 * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
103 * 124 *
@@ -196,27 +217,6 @@ abstract class AbstractImport implements ImportInterface
196 } 217 }
197 218
198 /** 219 /**
199 * {@inheritdoc}
200 */
201 public function getSummary()
202 {
203 return [
204 'skipped' => $this->skippedEntries,
205 'imported' => $this->importedEntries,
206 'queued' => $this->queuedEntries,
207 ];
208 }
209
210 /**
211 * Parse one entry.
212 *
213 * @param array $importedEntry
214 *
215 * @return Entry
216 */
217 abstract public function parseEntry(array $importedEntry);
218
219 /**
220 * Set current imported entry to archived / read. 220 * Set current imported entry to archived / read.
221 * Implementation is different accross all imports. 221 * Implementation is different accross all imports.
222 * 222 *
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 @@
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Wallabag\CoreBundle\Entity\Entry; 5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Event\EntrySavedEvent; 6use Wallabag\CoreBundle\Event\EntrySavedEvent;
7use Wallabag\UserBundle\Entity\User;
8 8
9abstract class BrowserImport extends AbstractImport 9abstract class BrowserImport extends AbstractImport
10{ 10{
@@ -74,6 +74,80 @@ abstract class BrowserImport extends AbstractImport
74 } 74 }
75 75
76 /** 76 /**
77 * {@inheritdoc}
78 */
79 public function parseEntry(array $importedEntry)
80 {
81 if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
82 if ($this->producer) {
83 $this->parseEntriesForProducer($importedEntry);
84
85 return;
86 }
87
88 $this->parseEntries($importedEntry);
89
90 return;
91 }
92
93 if (array_key_exists('children', $importedEntry)) {
94 if ($this->producer) {
95 $this->parseEntriesForProducer($importedEntry['children']);
96
97 return;
98 }
99
100 $this->parseEntries($importedEntry['children']);
101
102 return;
103 }
104
105 if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
106 return;
107 }
108
109 $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
110
111 $existingEntry = $this->em
112 ->getRepository('WallabagCoreBundle:Entry')
113 ->findByUrlAndUserId($url, $this->user->getId());
114
115 if (false !== $existingEntry) {
116 ++$this->skippedEntries;
117
118 return;
119 }
120
121 $data = $this->prepareEntry($importedEntry);
122
123 $entry = new Entry($this->user);
124 $entry->setUrl($data['url']);
125 $entry->setTitle($data['title']);
126
127 // update entry with content (in case fetching failed, the given entry will be return)
128 $this->fetchContent($entry, $data['url'], $data);
129
130 if (array_key_exists('tags', $data)) {
131 $this->tagsAssigner->assignTagsToEntry(
132 $entry,
133 $data['tags']
134 );
135 }
136
137 $entry->setArchived($data['is_archived']);
138
139 if (!empty($data['created_at'])) {
140 $dt = new \DateTime();
141 $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
142 }
143
144 $this->em->persist($entry);
145 ++$this->importedEntries;
146
147 return $entry;
148 }
149
150 /**
77 * Parse and insert all given entries. 151 * Parse and insert all given entries.
78 * 152 *
79 * @param $entries 153 * @param $entries
@@ -152,80 +226,6 @@ abstract class BrowserImport extends AbstractImport
152 /** 226 /**
153 * {@inheritdoc} 227 * {@inheritdoc}
154 */ 228 */
155 public function parseEntry(array $importedEntry)
156 {
157 if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
158 if ($this->producer) {
159 $this->parseEntriesForProducer($importedEntry);
160
161 return;
162 }
163
164 $this->parseEntries($importedEntry);
165
166 return;
167 }
168
169 if (array_key_exists('children', $importedEntry)) {
170 if ($this->producer) {
171 $this->parseEntriesForProducer($importedEntry['children']);
172
173 return;
174 }
175
176 $this->parseEntries($importedEntry['children']);
177
178 return;
179 }
180
181 if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
182 return;
183 }
184
185 $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
186
187 $existingEntry = $this->em
188 ->getRepository('WallabagCoreBundle:Entry')
189 ->findByUrlAndUserId($url, $this->user->getId());
190
191 if (false !== $existingEntry) {
192 ++$this->skippedEntries;
193
194 return;
195 }
196
197 $data = $this->prepareEntry($importedEntry);
198
199 $entry = new Entry($this->user);
200 $entry->setUrl($data['url']);
201 $entry->setTitle($data['title']);
202
203 // update entry with content (in case fetching failed, the given entry will be return)
204 $this->fetchContent($entry, $data['url'], $data);
205
206 if (array_key_exists('tags', $data)) {
207 $this->tagsAssigner->assignTagsToEntry(
208 $entry,
209 $data['tags']
210 );
211 }
212
213 $entry->setArchived($data['is_archived']);
214
215 if (!empty($data['created_at'])) {
216 $dt = new \DateTime();
217 $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
218 }
219
220 $this->em->persist($entry);
221 ++$this->importedEntries;
222
223 return $entry;
224 }
225
226 /**
227 * {@inheritdoc}
228 */
229 protected function setEntryAsRead(array $importedEntry) 229 protected function setEntryAsRead(array $importedEntry)
230 { 230 {
231 $importedEntry['is_archived'] = 1; 231 $importedEntry['is_archived'] = 1;
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
index 2667890f..e3ba636a 100644
--- a/src/Wallabag/ImportBundle/Import/ChromeImport.php
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -45,7 +45,7 @@ class ChromeImport extends BrowserImport
45 'created_at' => substr($entry['date_added'], 0, 10), 45 'created_at' => substr($entry['date_added'], 0, 10),
46 ]; 46 ];
47 47
48 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 48 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
49 $data['tags'] = $entry['tags']; 49 $data['tags'] = $entry['tags'];
50 } 50 }
51 51
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
index c50c69b3..c18e7e93 100644
--- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -45,7 +45,7 @@ class FirefoxImport extends BrowserImport
45 'created_at' => substr($entry['dateAdded'], 0, 10), 45 'created_at' => substr($entry['dateAdded'], 0, 10),
46 ]; 46 ];
47 47
48 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 48 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
49 $data['tags'] = $entry['tags']; 49 $data['tags'] = $entry['tags'];
50 } 50 }
51 51
diff --git a/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php b/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
index a363a566..d7df0a83 100644
--- a/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
+++ b/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; 5use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6use Symfony\Component\DependencyInjection\ContainerBuilder;
7use Symfony\Component\DependencyInjection\Reference; 7use Symfony\Component\DependencyInjection\Reference;
8 8
9class ImportCompilerPass implements CompilerPassInterface 9class ImportCompilerPass implements CompilerPassInterface
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index 3aa12f6f..7d70154a 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -72,7 +72,7 @@ class InstapaperImport extends AbstractImport
72 // BUT it can also be the status (since status = folder in Instapaper) 72 // BUT it can also be the status (since status = folder in Instapaper)
73 // and we don't want archive, unread & starred to become a tag 73 // and we don't want archive, unread & starred to become a tag
74 $tags = null; 74 $tags = null;
75 if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) { 75 if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'], true)) {
76 $tags = [$data[3]]; 76 $tags = [$data[3]];
77 } 77 }
78 78
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index c1d5b6da..7d38826b 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -8,11 +8,10 @@ use Wallabag\CoreBundle\Entity\Entry;
8 8
9class PocketImport extends AbstractImport 9class PocketImport extends AbstractImport
10{ 10{
11 const NB_ELEMENTS = 5000;
11 private $client; 12 private $client;
12 private $accessToken; 13 private $accessToken;
13 14
14 const NB_ELEMENTS = 5000;
15
16 /** 15 /**
17 * Only used for test purpose. 16 * Only used for test purpose.
18 * 17 *
@@ -176,7 +175,7 @@ class PocketImport extends AbstractImport
176 */ 175 */
177 public function parseEntry(array $importedEntry) 176 public function parseEntry(array $importedEntry)
178 { 177 {
179 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; 178 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
180 179
181 $existingEntry = $this->em 180 $existingEntry = $this->em
182 ->getRepository('WallabagCoreBundle:Entry') 181 ->getRepository('WallabagCoreBundle:Entry')
@@ -195,15 +194,15 @@ class PocketImport extends AbstractImport
195 $this->fetchContent($entry, $url); 194 $this->fetchContent($entry, $url);
196 195
197 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
198 $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead); 197 $entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
199 198
200 // 0 or 1 - 1 If the item is starred 199 // 0 or 1 - 1 If the item is starred
201 $entry->setStarred($importedEntry['favorite'] == 1); 200 $entry->setStarred($importedEntry['favorite'] === 1);
202 201
203 $title = 'Untitled'; 202 $title = 'Untitled';
204 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') { 203 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
205 $title = $importedEntry['resolved_title']; 204 $title = $importedEntry['resolved_title'];
206 } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] != '') { 205 } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
207 $title = $importedEntry['given_title']; 206 $title = $importedEntry['given_title'];
208 } 207 }
209 208
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 1f0df646..d585d44d 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -56,12 +56,12 @@ class WallabagV1Import extends WallabagImport
56 56
57 // In case of a bad fetch in v1, replace title and content with v2 error strings 57 // In case of a bad fetch in v1, replace title and content with v2 error strings
58 // If fetching fails again, they will get this instead of the v1 strings 58 // If fetching fails again, they will get this instead of the v1 strings
59 if (in_array($entry['title'], $this->untitled)) { 59 if (in_array($entry['title'], $this->untitled, true)) {
60 $data['title'] = $this->fetchingErrorMessageTitle; 60 $data['title'] = $this->fetchingErrorMessageTitle;
61 $data['html'] = $this->fetchingErrorMessage; 61 $data['html'] = $this->fetchingErrorMessage;
62 } 62 }
63 63
64 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 64 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
65 $data['tags'] = $entry['tags']; 65 $data['tags'] = $entry['tags'];
66 } 66 }
67 67
diff --git a/src/Wallabag/ImportBundle/Redis/Producer.php b/src/Wallabag/ImportBundle/Redis/Producer.php
index fedc3e57..c77b5174 100644
--- a/src/Wallabag/ImportBundle/Redis/Producer.php
+++ b/src/Wallabag/ImportBundle/Redis/Producer.php
@@ -29,7 +29,7 @@ class Producer implements ProducerInterface
29 * @param string $routingKey NOT USED 29 * @param string $routingKey NOT USED
30 * @param array $additionalProperties NOT USED 30 * @param array $additionalProperties NOT USED
31 */ 31 */
32 public function publish($msgBody, $routingKey = '', $additionalProperties = array()) 32 public function publish($msgBody, $routingKey = '', $additionalProperties = [])
33 { 33 {
34 $this->queue->sendJob($msgBody); 34 $this->queue->sendJob($msgBody);
35 } 35 }
diff --git a/src/Wallabag/ImportBundle/WallabagImportBundle.php b/src/Wallabag/ImportBundle/WallabagImportBundle.php
index a5ddc1b4..98c2f97b 100644
--- a/src/Wallabag/ImportBundle/WallabagImportBundle.php
+++ b/src/Wallabag/ImportBundle/WallabagImportBundle.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle; 3namespace Wallabag\ImportBundle;
4 4
5use Symfony\Component\HttpKernel\Bundle\Bundle;
6use Symfony\Component\DependencyInjection\ContainerBuilder; 5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\HttpKernel\Bundle\Bundle;
7use Wallabag\ImportBundle\Import\ImportCompilerPass; 7use Wallabag\ImportBundle\Import\ImportCompilerPass;
8 8
9class WallabagImportBundle extends Bundle 9class WallabagImportBundle extends Bundle
diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php
index 084f2c67..f3de656f 100644
--- a/src/Wallabag/UserBundle/Controller/ManageController.php
+++ b/src/Wallabag/UserBundle/Controller/ManageController.php
@@ -7,10 +7,10 @@ use FOS\UserBundle\FOSUserEvents;
7use Pagerfanta\Adapter\DoctrineORMAdapter; 7use Pagerfanta\Adapter\DoctrineORMAdapter;
8use Pagerfanta\Exception\OutOfRangeCurrentPageException; 8use Pagerfanta\Exception\OutOfRangeCurrentPageException;
9use Pagerfanta\Pagerfanta; 9use Pagerfanta\Pagerfanta;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 11use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12use Symfony\Bundle\FrameworkBundle\Controller\Controller;
13use Symfony\Component\HttpFoundation\Request;
14use Wallabag\UserBundle\Entity\User; 14use Wallabag\UserBundle\Entity\User;
15use Wallabag\UserBundle\Form\SearchUserType; 15use Wallabag\UserBundle\Form\SearchUserType;
16 16
@@ -48,13 +48,13 @@ class ManageController extends Controller
48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()]) 48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
49 ); 49 );
50 50
51 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 51 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
52 } 52 }
53 53
54 return $this->render('WallabagUserBundle:Manage:new.html.twig', array( 54 return $this->render('WallabagUserBundle:Manage:new.html.twig', [
55 'user' => $user, 55 'user' => $user,
56 'form' => $form->createView(), 56 'form' => $form->createView(),
57 )); 57 ]);
58 } 58 }
59 59
60 /** 60 /**
@@ -79,15 +79,15 @@ class ManageController extends Controller
79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()]) 79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
80 ); 80 );
81 81
82 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 82 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
83 } 83 }
84 84
85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', array( 85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', [
86 'user' => $user, 86 'user' => $user,
87 'edit_form' => $editForm->createView(), 87 'edit_form' => $editForm->createView(),
88 'delete_form' => $deleteForm->createView(), 88 'delete_form' => $deleteForm->createView(),
89 'twofactor_auth' => $this->getParameter('twofactor_auth'), 89 'twofactor_auth' => $this->getParameter('twofactor_auth'),
90 )); 90 ]);
91 } 91 }
92 92
93 /** 93 /**
@@ -116,22 +116,6 @@ class ManageController extends Controller
116 } 116 }
117 117
118 /** 118 /**
119 * Creates a form to delete a User entity.
120 *
121 * @param User $user The User entity
122 *
123 * @return \Symfony\Component\Form\Form The form
124 */
125 private function createDeleteForm(User $user)
126 {
127 return $this->createFormBuilder()
128 ->setAction($this->generateUrl('user_delete', array('id' => $user->getId())))
129 ->setMethod('DELETE')
130 ->getForm()
131 ;
132 }
133
134 /**
135 * @param Request $request 119 * @param Request $request
136 * @param int $page 120 * @param int $page
137 * 121 *
@@ -175,4 +159,20 @@ class ManageController extends Controller
175 'users' => $pagerFanta, 159 'users' => $pagerFanta,
176 ]); 160 ]);
177 } 161 }
162
163 /**
164 * Creates a form to delete a User entity.
165 *
166 * @param User $user The User entity
167 *
168 * @return \Symfony\Component\Form\Form The form
169 */
170 private function createDeleteForm(User $user)
171 {
172 return $this->createFormBuilder()
173 ->setAction($this->generateUrl('user_delete', ['id' => $user->getId()]))
174 ->setMethod('DELETE')
175 ->getForm()
176 ;
177 }
178} 178}
diff --git a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
index 99040f69..5ca3482e 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\UserBundle\DependencyInjection; 3namespace Wallabag\UserBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\Config\FileLocator; 5use Symfony\Component\Config\FileLocator;
7use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\DependencyInjection\ContainerBuilder;
8use Symfony\Component\DependencyInjection\Loader; 7use Symfony\Component\DependencyInjection\Loader;
8use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9 9
10class WallabagUserExtension extends Extension 10class WallabagUserExtension extends Extension
11{ 11{
@@ -14,7 +14,7 @@ class WallabagUserExtension extends Extension
14 $configuration = new Configuration(); 14 $configuration = new Configuration();
15 $config = $this->processConfiguration($configuration, $configs); 15 $config = $this->processConfiguration($configuration, $configs);
16 16
17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
18 $loader->load('services.yml'); 18 $loader->load('services.yml');
19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']); 19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
20 } 20 }
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index aba76ca7..20aca298 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -4,12 +4,12 @@ namespace Wallabag\UserBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use FOS\UserBundle\Model\User as BaseUser;
8use JMS\Serializer\Annotation\Accessor;
7use JMS\Serializer\Annotation\Groups; 9use JMS\Serializer\Annotation\Groups;
8use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
9use JMS\Serializer\Annotation\Accessor;
10use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; 11use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
11use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; 12use Scheb\TwoFactorBundle\Model\TrustedComputerInterface;
12use FOS\UserBundle\Model\User as BaseUser;
13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
14use Symfony\Component\Security\Core\User\UserInterface; 14use Symfony\Component\Security\Core\User\UserInterface;
15use Wallabag\ApiBundle\Entity\Client; 15use Wallabag\ApiBundle\Entity\Client;
@@ -93,36 +93,36 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
93 protected $config; 93 protected $config;
94 94
95 /** 95 /**
96 * @ORM\Column(type="integer", nullable=true) 96 * @var ArrayCollection
97 *
98 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
97 */ 99 */
98 private $authCode; 100 protected $clients;
99 101
100 /** 102 /**
101 * @var bool 103 * @see getFirstClient() below
102 * 104 *
103 * @ORM\Column(type="boolean") 105 * @Groups({"user_api_with_client"})
106 * @Accessor(getter="getFirstClient")
104 */ 107 */
105 private $twoFactorAuthentication = false; 108 protected $default_client;
106 109
107 /** 110 /**
108 * @ORM\Column(type="json_array", nullable=true) 111 * @ORM\Column(type="integer", nullable=true)
109 */ 112 */
110 private $trusted; 113 private $authCode;
111 114
112 /** 115 /**
113 * @var ArrayCollection 116 * @var bool
114 * 117 *
115 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"}) 118 * @ORM\Column(type="boolean")
116 */ 119 */
117 protected $clients; 120 private $twoFactorAuthentication = false;
118 121
119 /** 122 /**
120 * @see getFirstClient() below 123 * @ORM\Column(type="json_array", nullable=true)
121 *
122 * @Groups({"user_api_with_client"})
123 * @Accessor(getter="getFirstClient")
124 */ 124 */
125 protected $default_client; 125 private $trusted;
126 126
127 public function __construct() 127 public function __construct()
128 { 128 {
@@ -137,7 +137,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
137 */ 137 */
138 public function timestamps() 138 public function timestamps()
139 { 139 {
140 if (is_null($this->createdAt)) { 140 if (null === $this->createdAt) {
141 $this->createdAt = new \DateTime(); 141 $this->createdAt = new \DateTime();
142 } 142 }
143 143
diff --git a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
index 10f13233..18f14a3a 100644
--- a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
+++ b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
@@ -35,6 +35,6 @@ class AuthenticationFailureListener implements EventSubscriberInterface
35 { 35 {
36 $request = $this->requestStack->getMasterRequest(); 36 $request = $this->requestStack->getMasterRequest();
37 37
38 $this->logger->error('Authentication failure for user "'.$request->request->get('_username').'", from IP "'.$request->getClientIp().'", with UA: "'.$request->server->get('HTTP_USER_AGENT').'".'); 38 $this->logger->error('Authentication failure for user "' . $request->request->get('_username') . '", from IP "' . $request->getClientIp() . '", with UA: "' . $request->server->get('HTTP_USER_AGENT') . '".');
39 } 39 }
40} 40}
diff --git a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
index 3a7f2637..7df093f1 100644
--- a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
+++ b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\EventListener; 3namespace Wallabag\UserBundle\EventListener;
4 4
5use FOS\UserBundle\FOSUserEvents;
6use FOS\UserBundle\Event\FormEvent; 5use FOS\UserBundle\Event\FormEvent;
6use FOS\UserBundle\FOSUserEvents;
7use Symfony\Component\EventDispatcher\EventSubscriberInterface; 7use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8use Symfony\Component\HttpFoundation\RedirectResponse; 8use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php
index d8cdbaf9..56fea640 100644
--- a/src/Wallabag/UserBundle/Form/UserType.php
+++ b/src/Wallabag/UserBundle/Form/UserType.php
@@ -3,12 +3,12 @@
3namespace Wallabag\UserBundle\Form; 3namespace Wallabag\UserBundle\Form;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver;
8use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7use Symfony\Component\Form\Extension\Core\Type\EmailType;
9use Symfony\Component\Form\Extension\Core\Type\SubmitType; 8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
10use Symfony\Component\Form\Extension\Core\Type\TextType; 9use Symfony\Component\Form\Extension\Core\Type\TextType;
11use Symfony\Component\Form\Extension\Core\Type\EmailType; 10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver;
12 12
13class UserType extends AbstractType 13class UserType extends AbstractType
14{ 14{
@@ -50,8 +50,8 @@ class UserType extends AbstractType
50 */ 50 */
51 public function configureOptions(OptionsResolver $resolver) 51 public function configureOptions(OptionsResolver $resolver)
52 { 52 {
53 $resolver->setDefaults(array( 53 $resolver->setDefaults([
54 'data_class' => 'Wallabag\UserBundle\Entity\User', 54 'data_class' => 'Wallabag\UserBundle\Entity\User',
55 )); 55 ]);
56 } 56 }
57} 57}
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
index 961208f2..aed805c9 100644
--- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
+++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\Mailer; 3namespace Wallabag\UserBundle\Mailer;
4 4
5use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
6use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; 5use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface;
6use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
7 7
8/** 8/**
9 * Custom mailer for TwoFactorBundle email. 9 * Custom mailer for TwoFactorBundle email.
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 6adbe329..b1d753d2 100644
--- a/src/Wallabag/UserBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -63,6 +63,6 @@ class UserRepository extends EntityRepository
63 public function getQueryBuilderForSearch($term) 63 public function getQueryBuilderForSearch($term)
64 { 64 {
65 return $this->createQueryBuilder('u') 65 return $this->createQueryBuilder('u')
66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%'); 66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%');
67 } 67 }
68} 68}