aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/ConfigController.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 16:47:48 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 16:52:05 +0200
commitbf3dc999e7b25888460faff2251f75e4a79491c4 (patch)
treee529f9a322f7359141254ed6f05cc2c15ba845c3 /src/Wallabag/CoreBundle/Controller/ConfigController.php
parentc4bf7af96f52aaafd13049e74f27b368eec79bf8 (diff)
downloadwallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.gz
wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.zst
wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.zip
Add ability to edit a tagging rule
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/ConfigController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 75a9af0b..28e33998 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -108,7 +108,21 @@ class ConfigController extends Controller
108 108
109 // handle tagging rule 109 // handle tagging rule
110 $taggingRule = new TaggingRule(); 110 $taggingRule = new TaggingRule();
111 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']); 111 $action = $this->generateUrl('config').'#set5';
112
113 if ($request->query->has('tagging-rule')) {
114 $taggingRule = $this->getDoctrine()
115 ->getRepository('WallabagCoreBundle:TaggingRule')
116 ->find($request->query->get('tagging-rule'));
117
118 if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) {
119 return $this->redirect($action);
120 }
121
122 $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
123 }
124
125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
112 $newTaggingRule->handleRequest($request); 126 $newTaggingRule->handleRequest($request);
113 127
114 if ($newTaggingRule->isValid()) { 128 if ($newTaggingRule->isValid()) {
@@ -222,6 +236,24 @@ class ConfigController extends Controller
222 } 236 }
223 237
224 /** 238 /**
239 * Edit a tagging rule.
240 *
241 * @param TaggingRule $rule
242 *
243 * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule")
244 *
245 * @return RedirectResponse
246 */
247 public function editTaggingRuleAction(TaggingRule $rule)
248 {
249 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
250 throw $this->createAccessDeniedException('You can not access this tagging rule.');
251 }
252
253 return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
254 }
255
256 /**
225 * Retrieve config for the current user. 257 * Retrieve config for the current user.
226 * If no config were found, create a new one. 258 * If no config were found, create a new one.
227 * 259 *