aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle')
-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.php34
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php12
31 files changed, 337 insertions, 350 deletions
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..445cfeeb 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 ($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..a65bfe3b 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) {
@@ -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()),