aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php21
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php13
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php2
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php18
4 files changed, 25 insertions, 29 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 89d27425..d4170d39 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -152,8 +152,7 @@ class ConfigController extends Controller
152 ], 152 ],
153 'twofactor_auth' => $this->getParameter('twofactor_auth'), 153 'twofactor_auth' => $this->getParameter('twofactor_auth'),
154 'wallabag_url' => $this->getParameter('domain_name'), 154 'wallabag_url' => $this->getParameter('domain_name'),
155 'enabled_users' => $this->getDoctrine() 155 'enabled_users' => $this->get('wallabag_user.user_repository')
156 ->getRepository('WallabagUserBundle:User')
157 ->getSumEnabledUsers(), 156 ->getSumEnabledUsers(),
158 ]); 157 ]);
159 } 158 }
@@ -257,9 +256,7 @@ class ConfigController extends Controller
257 // manually remove tags to avoid orphan tag 256 // manually remove tags to avoid orphan tag
258 $this->removeAllTagsByUserId($this->getUser()->getId()); 257 $this->removeAllTagsByUserId($this->getUser()->getId());
259 258
260 $this->getDoctrine() 259 $this->get('wallabag_core.entry_repository')->removeAllByUserId($this->getUser()->getId());
261 ->getRepository('WallabagCoreBundle:Entry')
262 ->removeAllByUserId($this->getUser()->getId());
263 break; 260 break;
264 case 'archived': 261 case 'archived':
265 if ($this->get('doctrine')->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { 262 if ($this->get('doctrine')->getConnection()->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
@@ -269,9 +266,7 @@ class ConfigController extends Controller
269 // manually remove tags to avoid orphan tag 266 // manually remove tags to avoid orphan tag
270 $this->removeTagsForArchivedByUserId($this->getUser()->getId()); 267 $this->removeTagsForArchivedByUserId($this->getUser()->getId());
271 268
272 $this->getDoctrine() 269 $this->get('wallabag_core.entry_repository')->removeArchivedByUserId($this->getUser()->getId());
273 ->getRepository('WallabagCoreBundle:Entry')
274 ->removeArchivedByUserId($this->getUser()->getId());
275 break; 270 break;
276 } 271 }
277 272
@@ -295,8 +290,7 @@ class ConfigController extends Controller
295 return; 290 return;
296 } 291 }
297 292
298 $this->getDoctrine() 293 $this->get('wallabag_core.entry_repository')
299 ->getRepository('WallabagCoreBundle:Entry')
300 ->removeTags($userId, $tags); 294 ->removeTags($userId, $tags);
301 295
302 // cleanup orphan tags 296 // cleanup orphan tags
@@ -318,7 +312,7 @@ class ConfigController extends Controller
318 */ 312 */
319 private function removeAllTagsByUserId($userId) 313 private function removeAllTagsByUserId($userId)
320 { 314 {
321 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findAllTags($userId); 315 $tags = $this->get('wallabag_core.tag_repository')->findAllTags($userId);
322 $this->removeAllTagsByStatusAndUserId($tags, $userId); 316 $this->removeAllTagsByStatusAndUserId($tags, $userId);
323 } 317 }
324 318
@@ -329,7 +323,7 @@ class ConfigController extends Controller
329 */ 323 */
330 private function removeTagsForArchivedByUserId($userId) 324 private function removeTagsForArchivedByUserId($userId)
331 { 325 {
332 $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findForArchivedArticlesByUser($userId); 326 $tags = $this->get('wallabag_core.tag_repository')->findForArchivedArticlesByUser($userId);
333 $this->removeAllTagsByStatusAndUserId($tags, $userId); 327 $this->removeAllTagsByStatusAndUserId($tags, $userId);
334 } 328 }
335 329
@@ -393,8 +387,7 @@ class ConfigController extends Controller
393 */ 387 */
394 public function deleteAccountAction(Request $request) 388 public function deleteAccountAction(Request $request)
395 { 389 {
396 $enabledUsers = $this->getDoctrine() 390 $enabledUsers = $this->get('wallabag_user.user_repository')
397 ->getRepository('WallabagUserBundle:User')
398 ->getSumEnabledUsers(); 391 ->getSumEnabledUsers();
399 392
400 if ($enabledUsers <= 1) { 393 if ($enabledUsers <= 1) {
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index abc3336a..b9e5a974 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -57,16 +57,17 @@ class ExportController extends Controller
57 { 57 {
58 $method = ucfirst($category); 58 $method = ucfirst($category);
59 $methodBuilder = 'getBuilderFor'.$method.'ByUser'; 59 $methodBuilder = 'getBuilderFor'.$method.'ByUser';
60 $epository = $this->get('wallabag_core.entry_repository');
60 61
61 if ($category == 'tag_entries') { 62 if ($category == 'tag_entries') {
62 $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneBySlug($request->query->get('tag')); 63 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
63 64
64 $entries = $this->getDoctrine() 65 $entries = $epository->findAllByTagId(
65 ->getRepository('WallabagCoreBundle:Entry') 66 $this->getUser()->getId(),
66 ->findAllByTagId($this->getUser()->getId(), $tag->getId()); 67 $tag->getId()
68 );
67 } else { 69 } else {
68 $entries = $this->getDoctrine() 70 $entries = $epository
69 ->getRepository('WallabagCoreBundle:Entry')
70 ->$methodBuilder($this->getUser()->getId()) 71 ->$methodBuilder($this->getUser()->getId())
71 ->getQuery() 72 ->getQuery()
72 ->getResult(); 73 ->getResult();
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index 92f18707..5f7502fc 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -66,7 +66,7 @@ class RssController extends Controller
66 */ 66 */
67 private function showEntries($type, User $user, $page = 1) 67 private function showEntries($type, User $user, $page = 1)
68 { 68 {
69 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); 69 $repository = $this->get('wallabag_core.entry_repository');
70 70
71 switch ($type) { 71 switch ($type) {
72 case 'starred': 72 case 'starred':
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 9422bae4..72822479 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -84,16 +84,17 @@ class TagController extends Controller
84 */ 84 */
85 public function showTagAction() 85 public function showTagAction()
86 { 86 {
87 $tags = $this->getDoctrine() 87 $repository = $this->get('wallabag_core.entry_repository');
88 ->getRepository('WallabagCoreBundle:Tag') 88 $tags = $this->get('wallabag_core.tag_repository')
89 ->findAllTags($this->getUser()->getId()); 89 ->findAllTags($this->getUser()->getId());
90 90
91 $flatTags = []; 91 $flatTags = [];
92 92
93 foreach ($tags as $tag) { 93 foreach ($tags as $tag) {
94 $nbEntries = $this->getDoctrine() 94 $nbEntries = $repository->countAllEntriesByUserIdAndTagId(
95 ->getRepository('WallabagCoreBundle:Entry') 95 $this->getUser()->getId(),
96 ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag->getId()); 96 $tag->getId()
97 );
97 98
98 $flatTags[] = [ 99 $flatTags[] = [
99 'id' => $tag->getId(), 100 'id' => $tag->getId(),
@@ -119,9 +120,10 @@ class TagController extends Controller
119 */ 120 */
120 public function showEntriesForTagAction(Tag $tag, $page, Request $request) 121 public function showEntriesForTagAction(Tag $tag, $page, Request $request)
121 { 122 {
122 $entriesByTag = $this->getDoctrine() 123 $entriesByTag = $this->get('wallabag_core.entry_repository')->findAllByTagId(
123 ->getRepository('WallabagCoreBundle:Entry') 124 $this->getUser()->getId(),
124 ->findAllByTagId($this->getUser()->getId(), $tag->getId()); 125 $tag->getId()
126 );
125 127
126 $pagerAdapter = new ArrayAdapter($entriesByTag); 128 $pagerAdapter = new ArrayAdapter($entriesByTag);
127 129