@@ -17,12 +17,9 @@ |
||
| 17 | 17 | use FOS\UserBundle\Mailer\MailerInterface; |
| 18 | 18 | use Doctrine\ORM\EntityManager; |
| 19 | 19 | use LoginCidadao\CoreBundle\Entity\City; |
| 20 | -use Assetic\Exception\Exception; |
|
| 21 | 20 | use LoginCidadao\CoreBundle\Exception\LcValidationException; |
| 22 | -use LoginCidadao\NotificationBundle\Entity\Notification; |
|
| 23 | 21 | use LoginCidadao\CoreBundle\Entity\Person; |
| 24 | 22 | use LoginCidadao\CoreBundle\Entity\State; |
| 25 | -use LoginCidadao\CoreBundle\DynamicFormEvents; |
|
| 26 | 23 | use LoginCidadao\CoreBundle\Model\DynamicFormData; |
| 27 | 24 | use LoginCidadao\CoreBundle\Model\SelectData; |
| 28 | 25 | use LoginCidadao\CoreBundle\Model\PersonInterface; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $this->userManager = $var; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - private function checkEmailChanged(Person &$user) |
|
| 181 | + private function checkEmailChanged(Person & $user) |
|
| 182 | 182 | { |
| 183 | 183 | if ($user->getEmail() !== $this->email) { |
| 184 | 184 | if (is_null($user->getConfirmationToken())) { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - private function checkCPFChanged(Person &$user) |
|
| 197 | + private function checkCPFChanged(Person & $user) |
|
| 198 | 198 | { |
| 199 | 199 | if ($user->getCpf() !== $this->cpf) { |
| 200 | 200 | if ($user->getCpf()) { |
@@ -10,8 +10,6 @@ |
||
| 10 | 10 | use Symfony\Component\Form\FormEvents; |
| 11 | 11 | use Symfony\Component\Form\FormInterface; |
| 12 | 12 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 13 | -use Doctrine\ORM\EntityManager; |
|
| 14 | -use Doctrine\ORM\EntityRepository; |
|
| 15 | 13 | use LoginCidadao\CoreBundle\Entity\State; |
| 16 | 14 | use LoginCidadao\CoreBundle\Model\SelectData; |
| 17 | 15 | use LoginCidadao\CoreBundle\Model\Manager\CityManager; |
@@ -218,7 +218,7 @@ |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | public function finishView(FormView $view, FormInterface $form, |
| 221 | - array $options) |
|
| 221 | + array $options) |
|
| 222 | 222 | { |
| 223 | 223 | if ($view->children['country']->vars['choice_translation_domain'] === false) { |
| 224 | 224 | return; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $cityManager = $this->cityManager; |
| 75 | 75 | $level = $options['level']; |
| 76 | 76 | |
| 77 | - $refreshState = function (FormInterface $form, $countryId = null) use ($options, $stateManager, $level, $preferredChoiceCallback) { |
|
| 77 | + $refreshState = function(FormInterface $form, $countryId = null) use ($options, $stateManager, $level, $preferredChoiceCallback) { |
|
| 78 | 78 | if ($level === 'country') { |
| 79 | 79 | return; |
| 80 | 80 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | )); |
| 116 | 116 | }; |
| 117 | 117 | |
| 118 | - $refreshCity = function (FormInterface $form, $stateId = null) use ($options, $cityManager, $level) { |
|
| 118 | + $refreshCity = function(FormInterface $form, $stateId = null) use ($options, $cityManager, $level) { |
|
| 119 | 119 | if ($level === 'country' || $level === 'state') { |
| 120 | 120 | return; |
| 121 | 121 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | }; |
| 157 | 157 | |
| 158 | 158 | $builder->addEventListener(FormEvents::PRE_SET_DATA, |
| 159 | - function (FormEvent $event) use ($refreshState, $refreshCity, $level) { |
|
| 159 | + function(FormEvent $event) use ($refreshState, $refreshCity, $level) { |
|
| 160 | 160 | $form = $event->getForm(); |
| 161 | 161 | $data = $event->getData(); |
| 162 | 162 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | }); |
| 180 | 180 | |
| 181 | 181 | $builder->addEventListener(FormEvents::PRE_SUBMIT, |
| 182 | - function (FormEvent $event) use ($refreshState, $refreshCity, $level) { |
|
| 182 | + function(FormEvent $event) use ($refreshState, $refreshCity, $level) { |
|
| 183 | 183 | $form = $event->getForm(); |
| 184 | 184 | $data = $event->getData(); |
| 185 | 185 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | $collator = new \Collator($this->translator->getLocale()); |
| 227 | 227 | $translator = $this->translator; |
| 228 | - $sortFunction = function ($a, $b) use ($collator, $translator) { |
|
| 228 | + $sortFunction = function($a, $b) use ($collator, $translator) { |
|
| 229 | 229 | return $collator->compare($translator->trans($a->label), |
| 230 | 230 | $translator->trans($b->label)); |
| 231 | 231 | }; |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | private function getPreferredChoiceCallback() |
| 242 | 242 | { |
| 243 | - return function ($choice, $key) { |
|
| 243 | + return function($choice, $key) { |
|
| 244 | 244 | return $choice->getPreference() > 0; |
| 245 | 245 | }; |
| 246 | 246 | } |
@@ -6,14 +6,11 @@ |
||
| 6 | 6 | use Symfony\Component\Form\AbstractType; |
| 7 | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 8 | 8 | use Symfony\Component\Translation\TranslatorInterface; |
| 9 | -use LoginCidadao\CoreBundle\Form\DataTransformer\StateToStringTransformer; |
|
| 10 | 9 | use LoginCidadao\CoreBundle\Entity\Country; |
| 11 | 10 | use Doctrine\ORM\EntityManager; |
| 12 | -use Doctrine\ORM\EntityRepository; |
|
| 13 | 11 | use Symfony\Component\Form\FormEvent; |
| 14 | 12 | use Symfony\Component\Form\FormEvents; |
| 15 | 13 | use LoginCidadao\CoreBundle\Entity\State; |
| 16 | -use LoginCidadao\CoreBundle\Entity\City; |
|
| 17 | 14 | use LoginCidadao\CoreBundle\Entity\PersonAddress; |
| 18 | 15 | use LoginCidadao\CoreBundle\Model\SelectData; |
| 19 | 16 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 30 | 30 | { |
| 31 | 31 | $builder->addEventListener(FormEvents::PRE_SET_DATA, |
| 32 | - function (FormEvent $event) { |
|
| 32 | + function(FormEvent $event) { |
|
| 33 | 33 | $form = $event->getForm()->getParent(); |
| 34 | 34 | $person = $form->getData(); |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $form->add('city', new CitySelectorComboType($person->getState())); |
| 40 | 40 | }); |
| 41 | 41 | $builder->addEventListener(FormEvents::PRE_SUBMIT, |
| 42 | - function (FormEvent $event) { |
|
| 42 | + function(FormEvent $event) { |
|
| 43 | 43 | $data = $event->getData(); |
| 44 | 44 | $form = $event->getForm()->getParent(); |
| 45 | 45 | |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace LoginCidadao\CoreBundle\Form\Type; |
| 4 | 4 | |
| 5 | 5 | use Symfony\Component\Form\FormBuilderInterface; |
| 6 | -use Doctrine\ORM\EntityRepository; |
|
| 7 | 6 | use Symfony\Component\Form\FormEvent; |
| 8 | 7 | use Symfony\Component\Form\FormEvents; |
| 9 | 8 | use LoginCidadao\CoreBundle\Form\Type\CommonFormType; |
@@ -152,9 +152,9 @@ |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public static function filterRoles(PersonInterface $person, |
| 155 | - PersonInterface $loggedUser, |
|
| 156 | - FormInterface $form, array $roles, |
|
| 157 | - $securityHelper, $security) |
|
| 155 | + PersonInterface $loggedUser, |
|
| 156 | + FormInterface $form, array $roles, |
|
| 157 | + $securityHelper, $security) |
|
| 158 | 158 | { |
| 159 | 159 | $loggedUserLevel = $securityHelper->getLoggedInUserLevel(); |
| 160 | 160 | $targetPersonLevel = $securityHelper->getTargetPersonLevel($person); |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $securityHelper = $this->securityHelper; |
| 77 | 77 | $security = $this->security; |
| 78 | 78 | $builder->addEventListener(FormEvents::PRE_SET_DATA, |
| 79 | - function (FormEvent $event) use ($user, &$allRoles, &$securityHelper, &$security) { |
|
| 79 | + function(FormEvent $event) use ($user, &$allRoles, &$securityHelper, &$security) { |
|
| 80 | 80 | $person = $event->getData(); |
| 81 | 81 | $form = PersonResumeFormType::populateCountryStateCity($person, |
| 82 | 82 | $event->getForm()); |
@@ -4,12 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Symfony\Component\Form\FormBuilderInterface; |
| 6 | 6 | use Doctrine\ORM\EntityRepository; |
| 7 | -use LoginCidadao\CoreBundle\Entity\Country; |
|
| 8 | -use LoginCidadao\CoreBundle\Entity\State; |
|
| 9 | -use LoginCidadao\CoreBundle\Entity\City; |
|
| 10 | -use Symfony\Component\Form\FormEvent; |
|
| 11 | -use Symfony\Component\Form\FormEvents; |
|
| 12 | -use Doctrine\ORM\EntityManager; |
|
| 13 | 7 | use Symfony\Component\Form\AbstractType; |
| 14 | 8 | use Symfony\Component\Security\Core\SecurityContext; |
| 15 | 9 | |
@@ -21,27 +21,27 @@ |
||
| 21 | 21 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 22 | 22 | { |
| 23 | 23 | $builder->add('name', 'text', |
| 24 | - array( |
|
| 24 | + array( |
|
| 25 | 25 | 'required' => true |
| 26 | 26 | )); |
| 27 | 27 | $builder->add('default', 'text', |
| 28 | - array( |
|
| 28 | + array( |
|
| 29 | 29 | 'required' => false |
| 30 | 30 | )); |
| 31 | 31 | $builder->add('id', 'hidden', |
| 32 | - array( |
|
| 32 | + array( |
|
| 33 | 33 | 'required' => false |
| 34 | 34 | )); |
| 35 | 35 | $user = $this->getUser(); |
| 36 | 36 | $builder->add('category', 'hidden_entity', |
| 37 | - array( |
|
| 37 | + array( |
|
| 38 | 38 | 'required' => true, |
| 39 | 39 | 'class' => 'LoginCidadaoNotificationBundle:Category', |
| 40 | 40 | 'choice_label' => 'name', |
| 41 | 41 | 'query_builder' => function (EntityRepository $er) use(&$user) { |
| 42 | 42 | return $er->createQueryBuilder('u') |
| 43 | 43 | ->join('LoginCidadaoOAuthBundle:Client', 'c', 'with', |
| 44 | - 'u.client = c') |
|
| 44 | + 'u.client = c') |
|
| 45 | 45 | ->where(':person MEMBER OF c.owners') |
| 46 | 46 | ->setParameter('person', $user) |
| 47 | 47 | ->orderBy('u.id', 'desc'); |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | 'required' => true, |
| 39 | 39 | 'class' => 'LoginCidadaoNotificationBundle:Category', |
| 40 | 40 | 'choice_label' => 'name', |
| 41 | - 'query_builder' => function (EntityRepository $er) use(&$user) { |
|
| 41 | + 'query_builder' => function(EntityRepository $er) use(&$user) { |
|
| 42 | 42 | return $er->createQueryBuilder('u') |
| 43 | 43 | ->join('LoginCidadaoOAuthBundle:Client', 'c', 'with', |
| 44 | 44 | 'u.client = c') |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Symfony\Component\Form\FormEvent; |
| 8 | 8 | use Symfony\Component\Form\FormEvents; |
| 9 | 9 | use Symfony\Component\OptionsResolver\OptionsResolver; |
| 10 | -use Doctrine\ORM\EntityManager; |
|
| 11 | 10 | use Doctrine\ORM\EntityRepository; |
| 12 | 11 | use LoginCidadao\CoreBundle\Entity\State; |
| 13 | 12 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function buildForm(FormBuilderInterface $builder, array $options) |
| 30 | 30 | { |
| 31 | 31 | $builder->addEventListener(FormEvents::PRE_SET_DATA, |
| 32 | - function (FormEvent $event) { |
|
| 32 | + function(FormEvent $event) { |
|
| 33 | 33 | $form = $event->getForm()->getParent(); |
| 34 | 34 | $person = $form->getData(); |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $form->add('city', new CitySelectorComboType($person->getState())); |
| 40 | 40 | }); |
| 41 | 41 | $builder->addEventListener(FormEvents::PRE_SUBMIT, |
| 42 | - function (FormEvent $event) { |
|
| 42 | + function(FormEvent $event) { |
|
| 43 | 43 | $data = $event->getData(); |
| 44 | 44 | $form = $event->getForm()->getParent(); |
| 45 | 45 | |
@@ -5,12 +5,10 @@ |
||
| 5 | 5 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
| 6 | 6 | use Symfony\Component\HttpFoundation\Request; |
| 7 | 7 | use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; |
| 8 | -use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; |
|
| 9 | 8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 10 | 9 | use Symfony\Component\HttpFoundation\Session\Session; |
| 11 | 10 | use Symfony\Component\Routing\RouterInterface; |
| 12 | 11 | use Doctrine\ORM\EntityManager; |
| 13 | -use LoginCidadao\CoreBundle\Entity\Person; |
|
| 14 | 12 | use LoginCidadao\CoreBundle\Entity\AccessSession; |
| 15 | 13 | use Symfony\Component\Security\Http\HttpUtils; |
| 16 | 14 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use LoginCidadao\NotificationBundle\Entity\Notification; |
| 15 | 15 | use LoginCidadao\CoreBundle\Helper\GridHelper; |
| 16 | 16 | use LoginCidadao\NotificationBundle\Entity\Broadcast; |
| 17 | -use LoginCidadao\NotificationBundle\Handler\NotificationHandler; |
|
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * @Route("/dev/broadcasts") |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $em->persist($broadcast); |
| 113 | 113 | $em->flush(); |
| 114 | 114 | $url = $this->generateUrl('lc_dev_broadcast_settings', |
| 115 | - array('broadcastId' => $broadcast->getId())); |
|
| 115 | + array('broadcastId' => $broadcast->getId())); |
|
| 116 | 116 | return $this->redirect($url); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -138,23 +138,23 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $form->handleRequest($request); |
| 140 | 140 | if ($form->isValid()) { |
| 141 | - $placeholders = $form->get('placeholders')->getData(); |
|
| 142 | - $broadcast->setHtmlTemplate($placeholders, $form->get('title')->getData(), $form->get('shortText')->getData()); |
|
| 141 | + $placeholders = $form->get('placeholders')->getData(); |
|
| 142 | + $broadcast->setHtmlTemplate($placeholders, $form->get('title')->getData(), $form->get('shortText')->getData()); |
|
| 143 | 143 | |
| 144 | - $translator = $this->get('translator'); |
|
| 145 | - if ($form->get('saveAndAdd')->isClicked()) { |
|
| 144 | + $translator = $this->get('translator'); |
|
| 145 | + if ($form->get('saveAndAdd')->isClicked()) { |
|
| 146 | 146 | $this->sendBroadcast($broadcast, $form->get('shortText')->getData(), $form->get('title')->getData()); |
| 147 | 147 | $broadcast->setSent(true); |
| 148 | 148 | $this->get('session')->getFlashBag()->add('success', $translator->trans("Broadcast sent")); |
| 149 | - } else { |
|
| 149 | + } else { |
|
| 150 | 150 | $this->get('session')->getFlashBag()->add('success', $translator->trans("Broadcast saved")); |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - $em = $this->getDoctrine()->getManager(); |
|
| 154 | - $em->persist($broadcast); |
|
| 155 | - $em->flush(); |
|
| 153 | + $em = $this->getDoctrine()->getManager(); |
|
| 154 | + $em->persist($broadcast); |
|
| 155 | + $em->flush(); |
|
| 156 | 156 | |
| 157 | - return $this->redirect($this->generateUrl('lc_dev_broadcasts')); |
|
| 157 | + return $this->redirect($this->generateUrl('lc_dev_broadcasts')); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | return array('form' => $form->createView()); |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | $html = $broadcast->getHtmlTemplate(); |
| 166 | 166 | |
| 167 | 167 | foreach ($broadcast->getReceivers() as $person) { |
| 168 | - $notification = new Notification(); |
|
| 169 | - $notification->setIcon($broadcast->getCategory()->getDefaultIcon()); |
|
| 170 | - //$notification->setCallbackUrl("url"); |
|
| 171 | - $notification->setShortText($shortText); |
|
| 172 | - $notification->setTitle($title); |
|
| 173 | - $notification->setHtmlTemplate($html); |
|
| 174 | - $notification->setPerson($person); |
|
| 175 | - $notification->setSender($broadcast->getCategory()->getClient()); |
|
| 176 | - $notification->setCategory($broadcast->getCategory()); |
|
| 177 | - $notification->setMailTemplate($broadcast->getMailTemplate()); |
|
| 178 | - |
|
| 179 | - $helper->send($notification); |
|
| 168 | + $notification = new Notification(); |
|
| 169 | + $notification->setIcon($broadcast->getCategory()->getDefaultIcon()); |
|
| 170 | + //$notification->setCallbackUrl("url"); |
|
| 171 | + $notification->setShortText($shortText); |
|
| 172 | + $notification->setTitle($title); |
|
| 173 | + $notification->setHtmlTemplate($html); |
|
| 174 | + $notification->setPerson($person); |
|
| 175 | + $notification->setSender($broadcast->getCategory()->getClient()); |
|
| 176 | + $notification->setCategory($broadcast->getCategory()); |
|
| 177 | + $notification->setMailTemplate($broadcast->getMailTemplate()); |
|
| 178 | + |
|
| 179 | + $helper->send($notification); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | return array('grid' => $grid->createView($request)); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - private function getBroadcastGrid(){ |
|
| 35 | + private function getBroadcastGrid() { |
|
| 36 | 36 | $em = $this->getDoctrine()->getManager(); |
| 37 | 37 | $sql = $em->getRepository('LoginCidadaoNotificationBundle:Broadcast')->createQueryBuilder('c') |
| 38 | 38 | ->where('c.person = :person') |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $sql = $em->getRepository('LoginCidadaoCoreBundle:Person')->getFindAuthorizedByClientIdQuery($parms['client_id']); |
| 200 | 200 | $sql->andWhere('p.cpf like ?1 or p.username like ?1 or p.email like ?1 or p.firstName like ?1 or p.surname like ?1'); |
| 201 | 201 | $sql->setParameter('1', |
| 202 | - '%' . addcslashes($parms['username'], '\\%_') . '%'); |
|
| 202 | + '%'.addcslashes($parms['username'], '\\%_').'%'); |
|
| 203 | 203 | $sql->addOrderBy('p.id', 'desc'); |
| 204 | 204 | $grid->setQueryBuilder($sql); |
| 205 | 205 | } |
@@ -2,10 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace LoginCidadao\NotificationBundle\Controller\JsAPI; |
| 4 | 4 | |
| 5 | -use FOS\RestBundle\Util\Codes; |
|
| 6 | 5 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
| 7 | -use Symfony\Component\HttpFoundation\Request; |
|
| 8 | -use FOS\RestBundle\Request\ParamFetcherInterface; |
|
| 9 | 6 | use FOS\RestBundle\Controller\Annotations as REST; |
| 10 | 7 | use FOS\RestBundle\Controller\FOSRestController; |
| 11 | 8 | use LoginCidadao\NotificationBundle\Handler\NotificationHandlerInterface; |