aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-04-12 11:36:01 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-04-12 12:25:29 +0200
commit4094ea47712efbe58624ff74daeb1f77c9b0edcf (patch)
tree3d2c168092d0208e6ba888de969252a54bf0c6c1 /src/Wallabag/CoreBundle/Controller
parent7eccbda99f16dc39ee01a0c81ab88293e9b268fd (diff)
downloadwallabag-4094ea47712efbe58624ff74daeb1f77c9b0edcf.tar.gz
wallabag-4094ea47712efbe58624ff74daeb1f77c9b0edcf.tar.zst
wallabag-4094ea47712efbe58624ff74daeb1f77c9b0edcf.zip
Convert array + phpDoc
Thanks for https://github.com/thomasbachem/php-short-array-syntax-converter
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php38
-rw-r--r--src/Wallabag/CoreBundle/Controller/DeveloperController.php14
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php32
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php10
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php4
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php11
7 files changed, 63 insertions, 54 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 779be268..ccc3e8a1 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -32,7 +32,7 @@ class ConfigController extends Controller
32 $user = $this->getUser(); 32 $user = $this->getUser();
33 33
34 // handle basic config detail (this form is defined as a service) 34 // handle basic config detail (this form is defined as a service)
35 $configForm = $this->createForm(ConfigType::class, $config, array('action' => $this->generateUrl('config'))); 35 $configForm = $this->createForm(ConfigType::class, $config, ['action' => $this->generateUrl('config')]);
36 $configForm->handleRequest($request); 36 $configForm->handleRequest($request);
37 37
38 if ($configForm->isValid()) { 38 if ($configForm->isValid()) {
@@ -52,7 +52,7 @@ class ConfigController extends Controller
52 } 52 }
53 53
54 // handle changing password 54 // handle changing password
55 $pwdForm = $this->createForm(ChangePasswordType::class, null, array('action' => $this->generateUrl('config').'#set4')); 55 $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']);
56 $pwdForm->handleRequest($request); 56 $pwdForm->handleRequest($request);
57 57
58 if ($pwdForm->isValid()) { 58 if ($pwdForm->isValid()) {
@@ -71,10 +71,10 @@ class ConfigController extends Controller
71 } 71 }
72 72
73 // handle changing user information 73 // handle changing user information
74 $userForm = $this->createForm(UserInformationType::class, $user, array( 74 $userForm = $this->createForm(UserInformationType::class, $user, [
75 'validation_groups' => array('Profile'), 75 'validation_groups' => ['Profile'],
76 'action' => $this->generateUrl('config').'#set3', 76 'action' => $this->generateUrl('config').'#set3',
77 )); 77 ]);
78 $userForm->handleRequest($request); 78 $userForm->handleRequest($request);
79 79
80 if ($userForm->isValid()) { 80 if ($userForm->isValid()) {
@@ -89,7 +89,7 @@ class ConfigController extends Controller
89 } 89 }
90 90
91 // handle rss information 91 // handle rss information
92 $rssForm = $this->createForm(RssType::class, $config, array('action' => $this->generateUrl('config').'#set2')); 92 $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']);
93 $rssForm->handleRequest($request); 93 $rssForm->handleRequest($request);
94 94
95 if ($rssForm->isValid()) { 95 if ($rssForm->isValid()) {
@@ -106,7 +106,7 @@ class ConfigController extends Controller
106 106
107 // handle tagging rule 107 // handle tagging rule
108 $taggingRule = new TaggingRule(); 108 $taggingRule = new TaggingRule();
109 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, array('action' => $this->generateUrl('config').'#set5')); 109 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']);
110 $newTaggingRule->handleRequest($request); 110 $newTaggingRule->handleRequest($request);
111 111
112 if ($newTaggingRule->isValid()) { 112 if ($newTaggingRule->isValid()) {
@@ -126,10 +126,10 @@ class ConfigController extends Controller
126 $newUser = $userManager->createUser(); 126 $newUser = $userManager->createUser();
127 // enable created user by default 127 // enable created user by default
128 $newUser->setEnabled(true); 128 $newUser->setEnabled(true);
129 $newUserForm = $this->createForm(NewUserType::class, $newUser, array( 129 $newUserForm = $this->createForm(NewUserType::class, $newUser, [
130 'validation_groups' => array('Profile'), 130 'validation_groups' => ['Profile'],
131 'action' => $this->generateUrl('config').'#set6', 131 'action' => $this->generateUrl('config').'#set6',
132 )); 132 ]);
133 $newUserForm->handleRequest($request); 133 $newUserForm->handleRequest($request);
134 134
135 if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { 135 if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
@@ -147,27 +147,27 @@ class ConfigController extends Controller
147 147
148 $this->get('session')->getFlashBag()->add( 148 $this->get('session')->getFlashBag()->add(
149 'notice', 149 'notice',
150 $this->get('translator')->trans('flashes.config.notice.user_added', array('%username%' => $newUser->getUsername())) 150 $this->get('translator')->trans('flashes.config.notice.user_added', ['%username%' => $newUser->getUsername()])
151 ); 151 );
152 152
153 return $this->redirect($this->generateUrl('config').'#set6'); 153 return $this->redirect($this->generateUrl('config').'#set6');
154 } 154 }
155 155
156 return $this->render('WallabagCoreBundle:Config:index.html.twig', array( 156 return $this->render('WallabagCoreBundle:Config:index.html.twig', [
157 'form' => array( 157 'form' => [
158 'config' => $configForm->createView(), 158 'config' => $configForm->createView(),
159 'rss' => $rssForm->createView(), 159 'rss' => $rssForm->createView(),
160 'pwd' => $pwdForm->createView(), 160 'pwd' => $pwdForm->createView(),
161 'user' => $userForm->createView(), 161 'user' => $userForm->createView(),
162 'new_user' => $newUserForm->createView(), 162 'new_user' => $newUserForm->createView(),
163 'new_tagging_rule' => $newTaggingRule->createView(), 163 'new_tagging_rule' => $newTaggingRule->createView(),
164 ), 164 ],
165 'rss' => array( 165 'rss' => [
166 'username' => $user->getUsername(), 166 'username' => $user->getUsername(),
167 'token' => $config->getRssToken(), 167 'token' => $config->getRssToken(),
168 ), 168 ],
169 'twofactor_auth' => $this->getParameter('twofactor_auth'), 169 'twofactor_auth' => $this->getParameter('twofactor_auth'),
170 )); 170 ]);
171 } 171 }
172 172
173 /** 173 /**
@@ -187,7 +187,7 @@ class ConfigController extends Controller
187 $em->flush(); 187 $em->flush();
188 188
189 if ($request->isXmlHttpRequest()) { 189 if ($request->isXmlHttpRequest()) {
190 return new JsonResponse(array('token' => $config->getRssToken())); 190 return new JsonResponse(['token' => $config->getRssToken()]);
191 } 191 }
192 192
193 $this->get('session')->getFlashBag()->add( 193 $this->get('session')->getFlashBag()->add(
@@ -229,7 +229,7 @@ class ConfigController extends Controller
229 * Retrieve config for the current user. 229 * Retrieve config for the current user.
230 * If no config were found, create a new one. 230 * If no config were found, create a new one.
231 * 231 *
232 * @return Wallabag\CoreBundle\Entity\Config 232 * @return Config
233 */ 233 */
234 private function getConfig() 234 private function getConfig()
235 { 235 {
diff --git a/src/Wallabag/CoreBundle/Controller/DeveloperController.php b/src/Wallabag/CoreBundle/Controller/DeveloperController.php
index 7cb0ead2..d85ba5ee 100644
--- a/src/Wallabag/CoreBundle/Controller/DeveloperController.php
+++ b/src/Wallabag/CoreBundle/Controller/DeveloperController.php
@@ -21,9 +21,9 @@ class DeveloperController extends Controller
21 { 21 {
22 $clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll(); 22 $clients = $this->getDoctrine()->getRepository('WallabagApiBundle:Client')->findAll();
23 23
24 return $this->render('WallabagCoreBundle:Developer:index.html.twig', array( 24 return $this->render('WallabagCoreBundle:Developer:index.html.twig', [
25 'clients' => $clients, 25 'clients' => $clients,
26 )); 26 ]);
27 } 27 }
28 28
29 /** 29 /**
@@ -43,7 +43,7 @@ class DeveloperController extends Controller
43 $clientForm->handleRequest($request); 43 $clientForm->handleRequest($request);
44 44
45 if ($clientForm->isValid()) { 45 if ($clientForm->isValid()) {
46 $client->setAllowedGrantTypes(array('token', 'authorization_code', 'password', 'refresh_token')); 46 $client->setAllowedGrantTypes(['token', 'authorization_code', 'password', 'refresh_token']);
47 $em->persist($client); 47 $em->persist($client);
48 $em->flush(); 48 $em->flush();
49 49
@@ -52,15 +52,15 @@ class DeveloperController extends Controller
52 'flashes.developer.notice.client_created' 52 'flashes.developer.notice.client_created'
53 ); 53 );
54 54
55 return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', array( 55 return $this->render('WallabagCoreBundle:Developer:client_parameters.html.twig', [
56 'client_id' => $client->getPublicId(), 56 'client_id' => $client->getPublicId(),
57 'client_secret' => $client->getSecret(), 57 'client_secret' => $client->getSecret(),
58 )); 58 ]);
59 } 59 }
60 60
61 return $this->render('WallabagCoreBundle:Developer:client.html.twig', array( 61 return $this->render('WallabagCoreBundle:Developer:client.html.twig', [
62 'form' => $clientForm->createView(), 62 'form' => $clientForm->createView(),
63 )); 63 ]);
64 } 64 }
65 65
66 /** 66 /**
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index cba58858..17b72bd1 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -54,10 +54,10 @@ class EntryController extends Controller
54 if (false !== $existingEntry) { 54 if (false !== $existingEntry) {
55 $this->get('session')->getFlashBag()->add( 55 $this->get('session')->getFlashBag()->add(
56 'notice', 56 'notice',
57 $this->get('translator')->trans('flashes.entry.notice.entry_already_saved', array('%date%' => $existingEntry->getCreatedAt()->format('d-m-Y'))) 57 $this->get('translator')->trans('flashes.entry.notice.entry_already_saved', ['%date%' => $existingEntry->getCreatedAt()->format('d-m-Y')])
58 ); 58 );
59 59
60 return $this->redirect($this->generateUrl('view', array('id' => $existingEntry->getId()))); 60 return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
61 } 61 }
62 62
63 $this->updateEntry($entry); 63 $this->updateEntry($entry);
@@ -69,9 +69,9 @@ class EntryController extends Controller
69 return $this->redirect($this->generateUrl('homepage')); 69 return $this->redirect($this->generateUrl('homepage'));
70 } 70 }
71 71
72 return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', array( 72 return $this->render('WallabagCoreBundle:Entry:new_form.html.twig', [
73 'form' => $form->createView(), 73 'form' => $form->createView(),
74 )); 74 ]);
75 } 75 }
76 76
77 /** 77 /**
@@ -131,12 +131,12 @@ class EntryController extends Controller
131 'flashes.entry.notice.entry_updated' 131 'flashes.entry.notice.entry_updated'
132 ); 132 );
133 133
134 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId()))); 134 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
135 } 135 }
136 136
137 return $this->render('WallabagCoreBundle:Entry:edit.html.twig', array( 137 return $this->render('WallabagCoreBundle:Entry:edit.html.twig', [
138 'form' => $form->createView(), 138 'form' => $form->createView(),
139 )); 139 ]);
140 } 140 }
141 141
142 /** 142 /**
@@ -257,17 +257,17 @@ class EntryController extends Controller
257 $entries->setCurrentPage($page); 257 $entries->setCurrentPage($page);
258 } catch (OutOfRangeCurrentPageException $e) { 258 } catch (OutOfRangeCurrentPageException $e) {
259 if ($page > 1) { 259 if ($page > 1) {
260 return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302); 260 return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
261 } 261 }
262 } 262 }
263 263
264 return $this->render( 264 return $this->render(
265 'WallabagCoreBundle:Entry:entries.html.twig', 265 'WallabagCoreBundle:Entry:entries.html.twig',
266 array( 266 [
267 'form' => $form->createView(), 267 'form' => $form->createView(),
268 'entries' => $entries, 268 'entries' => $entries,
269 'currentPage' => $page, 269 'currentPage' => $page,
270 ) 270 ]
271 ); 271 );
272 } 272 }
273 273
@@ -286,7 +286,7 @@ class EntryController extends Controller
286 286
287 return $this->render( 287 return $this->render(
288 'WallabagCoreBundle:Entry:entry.html.twig', 288 'WallabagCoreBundle:Entry:entry.html.twig',
289 array('entry' => $entry) 289 ['entry' => $entry]
290 ); 290 );
291 } 291 }
292 292
@@ -314,7 +314,7 @@ class EntryController extends Controller
314 $message 314 $message
315 ); 315 );
316 316
317 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId()))); 317 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
318 } 318 }
319 319
320 /** 320 /**
@@ -394,7 +394,7 @@ class EntryController extends Controller
394 // to avoid redirecting to the deleted entry. Ugh. 394 // to avoid redirecting to the deleted entry. Ugh.
395 $url = $this->generateUrl( 395 $url = $this->generateUrl(
396 'view', 396 'view',
397 array('id' => $entry->getId()), 397 ['id' => $entry->getId()],
398 UrlGeneratorInterface::ABSOLUTE_URL 398 UrlGeneratorInterface::ABSOLUTE_URL
399 ); 399 );
400 400
@@ -426,11 +426,11 @@ class EntryController extends Controller
426 /** 426 /**
427 * Check for existing entry, if it exists, redirect to it with a message. 427 * Check for existing entry, if it exists, redirect to it with a message.
428 * 428 *
429 * @param $entry 429 * @param Entry $entry
430 * 430 *
431 * @return array|bool 431 * @return Entry|bool
432 */ 432 */
433 private function checkIfEntryAlreadyExists($entry) 433 private function checkIfEntryAlreadyExists(Entry $entry)
434 { 434 {
435 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); 435 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
436 } 436 }
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index c8ef49a2..944c755d 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -16,12 +16,15 @@ class ExportController extends Controller
16 /** 16 /**
17 * Gets one entry content. 17 * Gets one entry content.
18 * 18 *
19 * @param Entry $entry 19 * @param Entry $entry
20 * @param string $format
20 * 21 *
21 * @Route("/export/{id}.{format}", name="export_entry", requirements={ 22 * @Route("/export/{id}.{format}", name="export_entry", requirements={
22 * "format": "epub|mobi|pdf|json|xml|txt|csv", 23 * "format": "epub|mobi|pdf|json|xml|txt|csv",
23 * "id": "\d+" 24 * "id": "\d+"
24 * }) 25 * })
26 *
27 * @return \Symfony\Component\HttpFoundation\Response
25 */ 28 */
26 public function downloadEntryAction(Entry $entry, $format) 29 public function downloadEntryAction(Entry $entry, $format)
27 { 30 {
@@ -38,10 +41,15 @@ class ExportController extends Controller
38 /** 41 /**
39 * Export all entries for current user. 42 * Export all entries for current user.
40 * 43 *
44 * @param string $format
45 * @param string $category
46 *
41 * @Route("/export/{category}.{format}", name="export_entries", requirements={ 47 * @Route("/export/{category}.{format}", name="export_entries", requirements={
42 * "format": "epub|mobi|pdf|json|xml|txt|csv", 48 * "format": "epub|mobi|pdf|json|xml|txt|csv",
43 * "category": "all|unread|starred|archive" 49 * "category": "all|unread|starred|archive"
44 * }) 50 * })
51 *
52 * @return \Symfony\Component\HttpFoundation\Response
45 */ 53 */
46 public function downloadEntriesAction($format, $category) 54 public function downloadEntriesAction($format, $category)
47 { 55 {
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index a4f7a200..2118885c 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -87,9 +87,9 @@ class RssController extends Controller
87 $perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit'); 87 $perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit');
88 $entries->setMaxPerPage($perPage); 88 $entries->setMaxPerPage($perPage);
89 89
90 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( 90 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', [
91 'type' => $type, 91 'type' => $type,
92 'entries' => $entries, 92 'entries' => $entries,
93 )); 93 ]);
94 } 94 }
95} 95}
diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php
index 5b7bd56e..b41302f8 100644
--- a/src/Wallabag/CoreBundle/Controller/StaticController.php
+++ b/src/Wallabag/CoreBundle/Controller/StaticController.php
@@ -14,7 +14,7 @@ class StaticController extends Controller
14 { 14 {
15 return $this->render( 15 return $this->render(
16 'WallabagCoreBundle:Static:howto.html.twig', 16 'WallabagCoreBundle:Static:howto.html.twig',
17 array() 17 []
18 ); 18 );
19 } 19 }
20 20
@@ -25,10 +25,10 @@ class StaticController extends Controller
25 { 25 {
26 return $this->render( 26 return $this->render(
27 'WallabagCoreBundle:Static:about.html.twig', 27 'WallabagCoreBundle:Static:about.html.twig',
28 array( 28 [
29 'version' => $this->getParameter('wallabag_core.version'), 29 'version' => $this->getParameter('wallabag_core.version'),
30 'paypal_url' => $this->getParameter('wallabag_core.paypal_url'), 30 'paypal_url' => $this->getParameter('wallabag_core.paypal_url'),
31 ) 31 ]
32 ); 32 );
33 } 33 }
34 34
@@ -39,7 +39,7 @@ class StaticController extends Controller
39 { 39 {
40 return $this->render( 40 return $this->render(
41 'WallabagCoreBundle:Static:quickstart.html.twig', 41 'WallabagCoreBundle:Static:quickstart.html.twig',
42 array() 42 []
43 ); 43 );
44 } 44 }
45} 45}
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index 1a1f8c3d..e8e9ecbe 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -13,6 +13,7 @@ class TagController extends Controller
13{ 13{
14 /** 14 /**
15 * @param Request $request 15 * @param Request $request
16 * @param Entry $entry
16 * 17 *
17 * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag") 18 * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
18 * 19 *
@@ -38,13 +39,13 @@ class TagController extends Controller
38 'flashes.tag.notice.tag_added' 39 'flashes.tag.notice.tag_added'
39 ); 40 );
40 41
41 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId()))); 42 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
42 } 43 }
43 44
44 return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array( 45 return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', [
45 'form' => $form->createView(), 46 'form' => $form->createView(),
46 'entry' => $entry, 47 'entry' => $entry,
47 )); 48 ]);
48 } 49 }
49 50
50 /** 51 /**
@@ -82,9 +83,9 @@ class TagController extends Controller
82 83
83 return $this->render( 84 return $this->render(
84 'WallabagCoreBundle:Tag:tags.html.twig', 85 'WallabagCoreBundle:Tag:tags.html.twig',
85 array( 86 [
86 'tags' => $tags, 87 'tags' => $tags,
87 ) 88 ]
88 ); 89 );
89 } 90 }
90} 91}