aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php28
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php6
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml5
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml2
4 files changed, 36 insertions, 5 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 6dd03c1b..ed31c536 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -420,6 +420,8 @@ class WallabagRestController extends FOSRestController
420 ->getRepository('WallabagCoreBundle:Entry') 420 ->getRepository('WallabagCoreBundle:Entry')
421 ->removeTag($this->getUser()->getId(), $tag); 421 ->removeTag($this->getUser()->getId(), $tag);
422 422
423 $this->cleanOrphanTag($tag);
424
423 $json = $this->get('serializer')->serialize($tag, 'json'); 425 $json = $this->get('serializer')->serialize($tag, 'json');
424 426
425 return (new JsonResponse())->setJson($json); 427 return (new JsonResponse())->setJson($json);
@@ -460,6 +462,8 @@ class WallabagRestController extends FOSRestController
460 ->getRepository('WallabagCoreBundle:Entry') 462 ->getRepository('WallabagCoreBundle:Entry')
461 ->removeTags($this->getUser()->getId(), $tags); 463 ->removeTags($this->getUser()->getId(), $tags);
462 464
465 $this->cleanOrphanTag($tags);
466
463 $json = $this->get('serializer')->serialize($tags, 'json'); 467 $json = $this->get('serializer')->serialize($tags, 'json');
464 468
465 return (new JsonResponse())->setJson($json); 469 return (new JsonResponse())->setJson($json);
@@ -484,6 +488,8 @@ class WallabagRestController extends FOSRestController
484 ->getRepository('WallabagCoreBundle:Entry') 488 ->getRepository('WallabagCoreBundle:Entry')
485 ->removeTag($this->getUser()->getId(), $tag); 489 ->removeTag($this->getUser()->getId(), $tag);
486 490
491 $this->cleanOrphanTag($tag);
492
487 $json = $this->get('serializer')->serialize($tag, 'json'); 493 $json = $this->get('serializer')->serialize($tag, 'json');
488 494
489 return (new JsonResponse())->setJson($json); 495 return (new JsonResponse())->setJson($json);
@@ -506,6 +512,28 @@ class WallabagRestController extends FOSRestController
506 } 512 }
507 513
508 /** 514 /**
515 * Remove orphan tag in case no entries are associated to it.
516 *
517 * @param Tag|array $tags
518 */
519 private function cleanOrphanTag($tags)
520 {
521 if (!is_array($tags)) {
522 $tags = [$tags];
523 }
524
525 $em = $this->getDoctrine()->getManager();
526
527 foreach ($tags as $tag) {
528 if (count($tag->getEntries()) === 0) {
529 $em->remove($tag);
530 }
531 }
532
533 $em->flush();
534 }
535
536 /**
509 * Validate that the first id is equal to the second one. 537 * Validate that the first id is equal to the second one.
510 * If not, throw exception. It means a user try to access information from an other user. 538 * If not, throw exception. It means a user try to access information from an other user.
511 * 539 *
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 623a6146..c5746734 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -63,10 +63,12 @@ class TagController extends Controller
63 $entry->removeTag($tag); 63 $entry->removeTag($tag);
64 $em = $this->getDoctrine()->getManager(); 64 $em = $this->getDoctrine()->getManager();
65 $em->flush(); 65 $em->flush();
66 if (count($tag->getEntries()) == 0) { 66
67 // remove orphan tag in case no entries are associated to it
68 if (count($tag->getEntries()) === 0) {
67 $em->remove($tag); 69 $em->remove($tag);
70 $em->flush();
68 } 71 }
69 $em->flush();
70 72
71 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); 73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'));
72 74
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index d1139846..a4b727f4 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -29,7 +29,7 @@ services:
29 arguments: 29 arguments:
30 - "@doctrine" 30 - "@doctrine"
31 31
32 wallabag_core.table_prefix_subscriber: 32 wallabag_core.subscriber.table_prefix:
33 class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber 33 class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber
34 arguments: 34 arguments:
35 - "%database_table_prefix%" 35 - "%database_table_prefix%"
@@ -119,9 +119,10 @@ services:
119 class: Predis\Client 119 class: Predis\Client
120 arguments: 120 arguments:
121 - 121 -
122 scheme: '%redis_scheme%'
122 host: '%redis_host%' 123 host: '%redis_host%'
123 port: '%redis_port%' 124 port: '%redis_port%'
124 schema: tcp 125 path: '%redis_path%'
125 126
126 wallabag_core.exception_controller: 127 wallabag_core.exception_controller:
127 class: Wallabag\CoreBundle\Controller\ExceptionController 128 class: Wallabag\CoreBundle\Controller\ExceptionController
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 9791a3b2..547e9c8b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -209,7 +209,7 @@ entry:
209 is_public_label: 'Publiczny' 209 is_public_label: 'Publiczny'
210 save_label: 'Zapisz' 210 save_label: 'Zapisz'
211 public: 211 public:
212 # shared_by_wallabag: "This article has been shared by <a href='%wallabag_instance%'>wallabag</a>" 212 shared_by_wallabag: "Ten artykuł został udostępniony przez <a href='%wallabag_instance%'>wallabag</a>"
213 213
214about: 214about:
215 page_title: 'O nas' 215 page_title: 'O nas'