1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-27 17:28:39 +00:00

Add ability to edit a tagging rule

This commit is contained in:
Jeremy Benoist 2016-10-01 16:47:48 +02:00
parent c4bf7af96f
commit bf3dc999e7
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
14 changed files with 95 additions and 14 deletions

View file

@ -108,7 +108,21 @@ class ConfigController extends Controller
// handle tagging rule
$taggingRule = new TaggingRule();
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']);
$action = $this->generateUrl('config').'#set5';
if ($request->query->has('tagging-rule')) {
$taggingRule = $this->getDoctrine()
->getRepository('WallabagCoreBundle:TaggingRule')
->find($request->query->get('tagging-rule'));
if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) {
return $this->redirect($action);
}
$action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
}
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
$newTaggingRule->handleRequest($request);
if ($newTaggingRule->isValid()) {
@ -221,6 +235,24 @@ class ConfigController extends Controller
return $this->redirect($this->generateUrl('config').'#set5');
}
/**
* Edit a tagging rule.
*
* @param TaggingRule $rule
*
* @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule")
*
* @return RedirectResponse
*/
public function editTaggingRuleAction(TaggingRule $rule)
{
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
throw $this->createAccessDeniedException('You can not access this tagging rule.');
}
return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
}
/**
* Retrieve config for the current user.
* If no config were found, create a new one.