@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace LoginCidadao\APIBundle\Controller; |
| 4 | 4 | |
| 5 | 5 | use FOS\RestBundle\Controller\FOSRestController; |
| 6 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 7 | 6 | use FOS\RestBundle\Controller\Annotations as REST; |
| 8 | 7 | use Symfony\Component\HttpFoundation\Request; |
| 9 | 8 | use LoginCidadao\CoreBundle\Entity\Country; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $query = $this->getDoctrine()->getRepository('LoginCidadaoCoreBundle:Country') |
| 26 | 26 | ->createQueryBuilder('cty') |
| 27 | - ->where('cty.reviewed = ' . Country::REVIEWED_OK) |
|
| 27 | + ->where('cty.reviewed = '.Country::REVIEWED_OK) |
|
| 28 | 28 | ->orderBy('cty.id', 'ASC'); |
| 29 | 29 | return $this->handleView($this->view($query->getQuery()->getResult(Query::HYDRATE_ARRAY))); |
| 30 | 30 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $query = $this->getDoctrine()->getRepository('LoginCidadaoCoreBundle:State') |
| 40 | 40 | ->createQueryBuilder('state') |
| 41 | - ->where('state.reviewed = ' . Country::REVIEWED_OK); |
|
| 41 | + ->where('state.reviewed = '.Country::REVIEWED_OK); |
|
| 42 | 42 | $country = $request->get('country_id'); |
| 43 | 43 | if ($country) { |
| 44 | 44 | $query->join('LoginCidadaoCoreBundle:Country', 'cty', 'WITH', 'state.country = cty'); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $query = $this->getDoctrine()->getRepository('LoginCidadaoCoreBundle:City') |
| 60 | 60 | ->createQueryBuilder('c') |
| 61 | - ->where('c.reviewed = ' . Country::REVIEWED_OK); |
|
| 61 | + ->where('c.reviewed = '.Country::REVIEWED_OK); |
|
| 62 | 62 | $country = $request->get('country_id'); |
| 63 | 63 | $state = $request->get('state_id'); |
| 64 | 64 | if ($country || $state) { |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | class BaseController extends FOSRestController |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param SerializationContext $context |
|
| 19 | + */ |
|
| 17 | 20 | protected function renderWithContext($content, $context = null) |
| 18 | 21 | { |
| 19 | 22 | $person = $this->getUser(); |
@@ -5,11 +5,9 @@ |
||
| 5 | 5 | use FOS\RestBundle\Controller\FOSRestController; |
| 6 | 6 | use JMS\Serializer\SerializationContext; |
| 7 | 7 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
| 8 | -use LoginCidadao\CoreBundle\Entity\Person; |
|
| 9 | 8 | use LoginCidadao\CoreBundle\Entity\Authorization; |
| 10 | 9 | use LoginCidadao\CoreBundle\Model\PersonInterface; |
| 11 | 10 | use LoginCidadao\OAuthBundle\Model\ClientInterface; |
| 12 | -use LoginCidadao\OAuthBundle\Model\ClientUser; |
|
| 13 | 11 | |
| 14 | 12 | class BaseController extends FOSRestController |
| 15 | 13 | { |
@@ -33,11 +33,11 @@ |
||
| 33 | 33 | $person = $this->getUser(); |
| 34 | 34 | $serializer = $this->get('jms_serializer'); |
| 35 | 35 | return $serializer->serialize($person, 'json', |
| 36 | - SerializationContext::create()->setGroups($scope)); |
|
| 36 | + SerializationContext::create()->setGroups($scope)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | protected function getClientScope(PersonInterface $user, |
| 40 | - ClientInterface $client = null) |
|
| 40 | + ClientInterface $client = null) |
|
| 41 | 41 | { |
| 42 | 42 | if ($client === null) { |
| 43 | 43 | $client = $this->getClient(); |
@@ -26,13 +26,11 @@ |
||
| 26 | 26 | * templateVar="failedCallbacks" |
| 27 | 27 | * ) |
| 28 | 28 | * |
| 29 | - * @param Request $request the request object |
|
| 30 | - * @param ParamFetcherInterface $paramFetcher param fetcher service |
|
| 31 | 29 | * |
| 32 | 30 | * @REST\Get("/notifications/callbacks/failed", name="api_1_get_failed_notification_callbacks") |
| 33 | 31 | * @Audit\Loggable(type="SELECT") |
| 34 | 32 | * |
| 35 | - * @return array |
|
| 33 | + * @return \Symfony\Component\HttpFoundation\Response |
|
| 36 | 34 | */ |
| 37 | 35 | public function getFailedByClientAction() |
| 38 | 36 | { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param ParamFetcherInterface $paramFetcher param fetcher service |
| 50 | 50 | * @Audit\Loggable(type="SELECT") |
| 51 | 51 | * |
| 52 | - * @return array |
|
| 52 | + * @return \Symfony\Component\HttpFoundation\Response |
|
| 53 | 53 | */ |
| 54 | 54 | public function getNotificationsAction(Request $request, |
| 55 | 55 | ParamFetcherInterface $paramFetcher) |
@@ -93,9 +93,8 @@ discard block |
||
| 93 | 93 | * } |
| 94 | 94 | * ) |
| 95 | 95 | * @REST\View(templateVar="notification") |
| 96 | - * @param Request $request the request object |
|
| 97 | 96 | * @param int $id |
| 98 | - * @return \LoginCidadao\NotificationBundle\Entity\Notification |
|
| 97 | + * @return \Symfony\Component\HttpFoundation\Response |
|
| 99 | 98 | * @throws NotFoundHttpException when notification not exist |
| 100 | 99 | * @throws AccessDeniedHttpException when trying to access another user's Notification |
| 101 | 100 | * @REST\Get("/notifications/{id}", name="api_1_get_notification") |
@@ -172,7 +171,7 @@ discard block |
||
| 172 | 171 | /** |
| 173 | 172 | * Fetch a Notification or throw an 404 Exception. |
| 174 | 173 | * |
| 175 | - * @param mixed $id |
|
| 174 | + * @param integer $id |
|
| 176 | 175 | * @return NotificationInterface |
| 177 | 176 | * @throws NotFoundHttpException |
| 178 | 177 | */ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | 54 | public function getNotificationsAction(Request $request, |
| 55 | - ParamFetcherInterface $paramFetcher) |
|
| 55 | + ParamFetcherInterface $paramFetcher) |
|
| 56 | 56 | { |
| 57 | 57 | $offset = $paramFetcher->get('offset'); |
| 58 | 58 | $offset = null == $offset ? 0 : $offset; |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (array_search('get_all_notifications', $scopes) === false) { |
| 66 | 66 | $notifications = $this->getNotificationHandler()->getAllFromPersonByClient($person, |
| 67 | - $client, |
|
| 68 | - $limit, |
|
| 69 | - $offset); |
|
| 67 | + $client, |
|
| 68 | + $limit, |
|
| 69 | + $offset); |
|
| 70 | 70 | } else { |
| 71 | 71 | $notifications = $this->getNotificationHandler()->getAllFromPerson($person, |
| 72 | - $limit, |
|
| 73 | - $offset); |
|
| 72 | + $limit, |
|
| 73 | + $offset); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | return $this->renderWithContext($notifications); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $user = $token->getUser(); |
| 193 | 193 | if ($user instanceof ClientUser) { |
| 194 | 194 | return $this->validateNotificationAsClient($user->getClient(), |
| 195 | - $request); |
|
| 195 | + $request); |
|
| 196 | 196 | } elseif ($user instanceof PersonInterface) { |
| 197 | 197 | return $this->validateNotificationAsPerson($user, $request); |
| 198 | 198 | } else { |
@@ -104,6 +104,9 @@ discard block |
||
| 104 | 104 | return $this->handleView($view); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | + /** |
|
| 108 | + * @param \Closure $callback |
|
| 109 | + */ |
|
| 107 | 110 | private function runTimeLimited($callback, $waitTime = 1) |
| 108 | 111 | { |
| 109 | 112 | $maxExecutionTime = ini_get('max_execution_time'); |
@@ -127,6 +130,9 @@ discard block |
||
| 127 | 130 | throw new RequestTimeoutException("Request Timeout"); |
| 128 | 131 | } |
| 129 | 132 | |
| 133 | + /** |
|
| 134 | + * @param \DateTime $updatedAt |
|
| 135 | + */ |
|
| 130 | 136 | private function getCheckUpdateCallback($id, $updatedAt, $lastUpdatedAt) |
| 131 | 137 | { |
| 132 | 138 | $em = $this->getDoctrine()->getEntityManager(); |
@@ -7,15 +7,11 @@ |
||
| 7 | 7 | use LoginCidadao\APIBundle\Exception\RequestTimeoutException; |
| 8 | 8 | use LoginCidadao\CoreBundle\Entity\Person; |
| 9 | 9 | use LoginCidadao\CoreBundle\Entity\Authorization; |
| 10 | -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
|
| 11 | -use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
|
| 12 | 10 | use Symfony\Component\HttpFoundation\Request; |
| 13 | -use Symfony\Component\HttpKernel\Exception\HttpException; |
|
| 14 | 11 | use LoginCidadao\NotificationBundle\Entity\Notification; |
| 15 | 12 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
| 16 | 13 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
| 17 | 14 | use LoginCidadao\CoreBundle\Model\PersonInterface; |
| 18 | -use LoginCidadao\OAuthBundle\Model\ClientInterface; |
|
| 19 | 15 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
| 20 | 16 | use LoginCidadao\OAuthBundle\Model\ClientUser; |
| 21 | 17 | use LoginCidadao\APIBundle\Security\Audit\Annotation as Audit; |
@@ -173,10 +173,10 @@ |
||
| 173 | 173 | ->createQueryBuilder('a') |
| 174 | 174 | ->select('cnc, p') |
| 175 | 175 | ->join('LoginCidadaoCoreBundle:Person', 'p', 'WITH', |
| 176 | - 'a.person = p') |
|
| 176 | + 'a.person = p') |
|
| 177 | 177 | ->join('LoginCidadaoOAuthBundle:Client', 'c', 'WITH', 'a.client = c') |
| 178 | 178 | ->join('LoginCidadaoCoreBundle:ConfigNotCli', 'cnc', 'WITH', |
| 179 | - 'cnc.client = c') |
|
| 179 | + 'cnc.client = c') |
|
| 180 | 180 | ->where('c.id = '.$client->getId().' and p.id = :person_id and cnc.id = :config_id') |
| 181 | 181 | ->getQuery(); |
| 182 | 182 | $rowR = array(); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $body = json_decode($request->getContent(), 1); |
| 169 | 169 | |
| 170 | - $chkAuth = $this->getDoctrine() |
|
| 170 | + $chkAuth = $this->getDoctrine() |
|
| 171 | 171 | ->getManager() |
| 172 | 172 | ->getRepository('LoginCidadaoCoreBundle:Authorization') |
| 173 | 173 | ->createQueryBuilder('a') |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $rowR[$idx] = array('person_id' => $row['person_id'], 'error' => 'missing authorization or configuration'); |
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | - $not = new Notification(); |
|
| 194 | + $not = new Notification(); |
|
| 195 | 195 | $not->setPerson($res[0]); |
| 196 | 196 | $not->setConfigNotCli($res[1]) |
| 197 | 197 | ->setIcon(isset($row['icon']) && $row['icon'] ? $row['icon'] |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ->findOneBy(array( |
| 243 | 243 | 'token' => $token->getToken() |
| 244 | 244 | )); |
| 245 | - $client = $accessToken->getClient(); |
|
| 245 | + $client = $accessToken->getClient(); |
|
| 246 | 246 | |
| 247 | 247 | $people = $this->getDoctrine()->getRepository('LoginCidadaoCoreBundle:Person'); |
| 248 | 248 | $person = $people->find($id); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | /** |
| 411 | 411 | * Get response code |
| 412 | 412 | * |
| 413 | - * @return integer |
|
| 413 | + * @return string |
|
| 414 | 414 | */ |
| 415 | 415 | public function getResponseCode() |
| 416 | 416 | { |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
| 431 | - * @return Client |
|
| 431 | + * @return ClientInterface |
|
| 432 | 432 | */ |
| 433 | 433 | public function getClient() |
| 434 | 434 | { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace LoginCidadao\APIBundle\Entity; |
| 4 | 4 | |
| 5 | 5 | use Doctrine\ORM\Mapping as ORM; |
| 6 | -use LoginCidadao\CoreBundle\Model\PersonInterface; |
|
| 7 | 6 | use LoginCidadao\OAuthBundle\Model\ClientInterface; |
| 8 | 7 | |
| 9 | 8 | /** |
@@ -79,6 +79,9 @@ |
||
| 79 | 79 | return $this; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + /** |
|
| 83 | + * @param string $logoutKey |
|
| 84 | + */ |
|
| 82 | 85 | public function setKey($logoutKey) |
| 83 | 86 | { |
| 84 | 87 | $this->logoutKey = $logoutKey; |
@@ -57,6 +57,9 @@ discard block |
||
| 57 | 57 | $annotation->setActionLogId($log->getId()); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param integer $responseCode |
|
| 62 | + */ |
|
| 60 | 63 | public function updateResponseCode($actionLogId, $responseCode) |
| 61 | 64 | { |
| 62 | 65 | |
@@ -83,7 +86,6 @@ discard block |
||
| 83 | 86 | } |
| 84 | 87 | |
| 85 | 88 | /** |
| 86 | - * @param Loggable $annotation |
|
| 87 | 89 | * @param Request $request |
| 88 | 90 | * @param array $controllerAction |
| 89 | 91 | * @param string $auditUsername |
@@ -137,6 +139,9 @@ discard block |
||
| 137 | 139 | $this->em->flush($log); |
| 138 | 140 | } |
| 139 | 141 | |
| 142 | + /** |
|
| 143 | + * @param boolean $isImpersonating |
|
| 144 | + */ |
|
| 140 | 145 | public function registerImpersonate(Request $request, |
| 141 | 146 | PersonInterface $person, |
| 142 | 147 | PersonInterface $impersonator, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return ActionLog |
| 91 | 91 | */ |
| 92 | 92 | private function initLog(Request $request, $actionType, $controllerAction, |
| 93 | - $auditUsername) |
|
| 93 | + $auditUsername) |
|
| 94 | 94 | { |
| 95 | 95 | $controller = get_class($controllerAction[0]); |
| 96 | 96 | $action = $controllerAction[1]; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function registerLogin(Request $request, PersonInterface $person, |
| 127 | - array $controllerAction) |
|
| 127 | + array $controllerAction) |
|
| 128 | 128 | { |
| 129 | 129 | $auditUsername = $this->auditConfig->getCurrentUsername(); |
| 130 | 130 | $actionType = ActionLog::TYPE_LOGIN; |
@@ -31,6 +31,9 @@ discard block |
||
| 31 | 31 | $this->createCategories($output); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $dir |
|
| 36 | + */ |
|
| 34 | 37 | private function loadDumpFiles($dir, OutputInterface $output) |
| 35 | 38 | { |
| 36 | 39 | $em = $this->getManager(); |
@@ -94,6 +97,10 @@ discard block |
||
| 94 | 97 | return compact('id', 'name', 'state_id', 'stat', 'reviewed'); |
| 95 | 98 | } |
| 96 | 99 | |
| 100 | + /** |
|
| 101 | + * @param string $fileName |
|
| 102 | + * @param \Doctrine\DBAL\Statement $query |
|
| 103 | + */ |
|
| 97 | 104 | private function loopInsert($dir, $fileName, $query, $prepareFunction, $debug = false) |
| 98 | 105 | { |
| 99 | 106 | $entries = 0; |
@@ -112,6 +119,9 @@ discard block |
||
| 112 | 119 | return $entries; |
| 113 | 120 | } |
| 114 | 121 | |
| 122 | + /** |
|
| 123 | + * @param string $dir |
|
| 124 | + */ |
|
| 115 | 125 | protected function createDefaultOAuthClient($dir, OutputInterface $output) |
| 116 | 126 | { |
| 117 | 127 | if (!($this->getDefaultOAuthClient() instanceof Client)) { |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
| 6 | 6 | use Symfony\Component\Console\Input\InputArgument; |
| 7 | 7 | use Symfony\Component\Console\Input\InputInterface; |
| 8 | -use Symfony\Component\Console\Input\InputOption; |
|
| 9 | 8 | use Symfony\Component\Console\Output\OutputInterface; |
| 10 | 9 | use Doctrine\ORM\EntityManager; |
| 11 | 10 | use LoginCidadao\NotificationBundle\Entity\Category; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | private function loopInsert($dir, $fileName, $query, $prepareFunction, $debug = false) |
| 98 | 98 | { |
| 99 | 99 | $entries = 0; |
| 100 | - $file = $dir . DIRECTORY_SEPARATOR . $fileName; |
|
| 100 | + $file = $dir.DIRECTORY_SEPARATOR.$fileName; |
|
| 101 | 101 | if (($handle = fopen($file, 'r')) !== false) { |
| 102 | 102 | while (($row = fgetcsv($handle)) !== false) { |
| 103 | 103 | $data = $prepareFunction($row); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if (!($this->getDefaultOAuthClient() instanceof Client)) { |
| 118 | 118 | $uid = $this->getContainer()->getParameter('oauth_default_client.uid'); |
| 119 | 119 | $pictureName = 'client_logo.png'; |
| 120 | - $picture = new File($dir . DIRECTORY_SEPARATOR . $pictureName); |
|
| 120 | + $picture = new File($dir.DIRECTORY_SEPARATOR.$pictureName); |
|
| 121 | 121 | $domain = $this->getContainer()->getParameter('site_domain'); |
| 122 | 122 | $url = "//$domain"; |
| 123 | 123 | $grantTypes = array( |