Esempio n. 1
0
 protected function getParams(RuleAction $action)
 {
     $params = $action->getRawParams();
     if (empty($params) || !is_array($params)) {
         $params = array();
     }
     if (!isset($params['category_id'])) {
         $params['category_id'] = '';
     }
     return $params;
 }
Esempio n. 2
0
 /**
  * @Route("/{rule_id}/add_action", name="add_action")
  *
  * @param Request $request
  * @param $rule_id
  * @return Response
  */
 public function addAction(Request $request, $rule_id)
 {
     $factory = $this->get('homefinance.rules.factory');
     $administration = $this->checkCurrentAdministration(Permission::EDIT);
     $repo = $this->getDoctrine()->getRepository('HomefinanceBundle:Rule');
     $rule = $repo->findOneByIdAndAdministration($administration, $rule_id);
     $action = new RuleAction();
     $action->setRule($rule);
     $form = $this->createForm('rules_action', $action);
     $form->get('actions')->add('save_add_action', 'submit', array('label' => 'rules.action.save_add_condition.btn-label', 'attr' => array('class' => 'btn btn-lg btn-primary')));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($action);
         $em->flush();
         $this->addFlash('success', 'action.edited');
         if ($factory->hasActionForm($action)) {
             $params = array('rule_id' => $rule_id, 'action_id' => $action->getId());
             if ($form->get('actions')->get('save_add_action')->isClicked()) {
                 $params['next'] = 'action';
             }
             return $this->redirect($this->generateUrl('edit_action', $params));
         }
         if ($form->get('actions')->get('save_add_action')->isClicked()) {
             return $this->redirect($this->generateUrl('add_action', array('rule_id' => $rule_id)));
         }
         return $this->redirect($this->generateUrl('rules'));
     }
     return $this->render('HomefinanceBundle:Rules:add_action.html.twig', array('form' => $form->createView()));
 }
Esempio n. 3
0
 public function getActionLabel(RuleAction $action)
 {
     $class = $this->getActionClass($action->getAction());
     return $class->getLabel($action);
 }