/** * List all status_keaktifans. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing status_keaktifans.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many status_keaktifans to return.") * * @Annotations\View( * templateVar="status_keaktifans" * ) * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getStatusKeaktifansAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ais_status_keaktifan.status_keaktifan.handler')->all($limit, $offset); }
/** * List all incidents. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @FOS\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing incidents.") * @FOS\QueryParam(name="limit", requirements="\d+", default="5", description="How many incidents to return.") * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getIncidentsAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('cert_unlp.ngen.incident.handler')->all([], [], $limit, $offset); }
/** * List all tags. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing tags.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many tags to return.") * * @Annotations\View( * templateVar="tags" * ) * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getTagsAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('acme_blog.tag.handler')->all($limit, $offset); }
/** * List all messages. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing messages.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many messages to return.") * * @Annotations\View( * templateVar="messages" * ) * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getMessagesAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('markettrade_demo.message.handler')->all($limit, $offset); }
/** * Get global highscore. * * @ApiDoc( * resource = true, * description = "Highscore", * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing level.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="10", description="How many users to return.") * * @author Benjamin Brandt * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * @return array */ public function getHighscoreAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('verbunden_blendoku.game.handler')->HighScore($limit, $offset); }
/** * Sign in users by pair username:password. * * @ApiDoc( * views={"default", "user"}, * section="Security API", * resource=true, * resourceDescription="Sign in users by pair username:password.", * statusCodes={ * 200="Returned when successful", * 400="Returned when an error has occurred", * } * ) * * @Rest\Route("/sign-in", requirements={ * "_format": "json|xml" * }) * * @Rest\RequestParam(name="username", requirements="[\w\-]+", nullable=false, description="Username") * @Rest\RequestParam(name="password", nullable=false, description="Password") * * @param ParamFetcherInterface $paramFetcher * @return View */ public function postUserSignInAction(ParamFetcherInterface $paramFetcher) { $username = $paramFetcher->get('username'); $password = $paramFetcher->get('password'); /** @var EntityRepository $repository */ $repository = $this->getDoctrine()->getManager()->getRepository('UserBundle:User'); /** @var User $user */ $user = $repository->findOneBy(['username' => $username]); if (!$user || !$this->validatePassword($user, $password)) { return new View(array('message' => 'User not found.'), 400); } if (!$user->isEnabled()) { return new View(array('message' => 'Account is disabled.'), 400); } if (!$user->isAccountNonLocked()) { return new View(array('message' => 'Account is locked.'), 400); } if (!$user->isAccountNonExpired()) { return new View(array('message' => 'Account is expired.'), 400); } if (!$user->isCredentialsNonExpired()) { return new View(array('message' => 'Credentials is expired.'), 400); } $this->generateToken($user); $this->getDoctrine()->getManager()->flush(); $headers = array('Token' => $user->getApiToken(), 'ExpireAt' => $user->getApiTokenExpireAt()->format('c'), 'Username' => $user->getUsername()); $view = new View(array_merge(array('user' => $user->getId()), $headers), 200, $headers); $this->setAuthInfoInCookie($headers, $view->getResponse(), $user->getApiTokenExpireAt()); return $view; }
/** * @REST\Post("/dispatchevent", name="api_dispatcher_dispatchevent", requirements={ "id"="\d+"}) * * @REST\RequestParam(name="eventkey", requirements="[a-z]+", description="Event key") * @REST\RequestParam(name="eventvalue", description="Event value") * * @param ParamFetcherInterface $paramFetcher * @return array */ public function dispatcheventAction(ParamFetcherInterface $paramFetcher) { $eventkey = $paramFetcher->get('eventkey'); $eventvalue = $paramFetcher->get('eventvalue'); $this->get('api.dispatcher')->dispatch($eventkey, $eventvalue); return []; }
/** * Get events for a school * * @ApiDoc( * resource = true, * description = "Get events for a school.", * output="Ilios\CoreBundle\Classes\SchoolEvent", * statusCodes = { * 200 = "List of school events", * } * ) * * @View(serializerEnableMaxDepthChecks=true) * * @param integer $id * @param ParamFetcherInterface $paramFetcher * * @return Response * * @QueryParam( * name="from", * requirements="\d+", * description="Timestamp for first event from time." * ) * @QueryParam( * name="to", * requirements="\d+", * description="Time stamp for last event from time" * ) */ public function getAction($id, ParamFetcherInterface $paramFetcher) { $schoolHandler = $this->container->get('ilioscore.school.handler'); $school = $schoolHandler->findSchoolBy(['id' => $id]); if (!$school) { throw new NotFoundHttpException(sprintf('The school \'%s\' was not found.', $id)); } $fromTimestamp = $paramFetcher->get('from'); $toTimestamp = $paramFetcher->get('to'); $from = DateTime::createFromFormat('U', $fromTimestamp); $to = DateTime::createFromFormat('U', $toTimestamp); if (!$from) { throw new InvalidInputWithSafeUserMessageException("?from is missing or is not a valid timestamp"); } if (!$to) { throw new InvalidInputWithSafeUserMessageException("?to is missing or is not a valid timestamp"); } $result = $schoolHandler->findEventsForSchool($school->getId(), $from, $to); $authChecker = $this->get('security.authorization_checker'); $result = array_filter($result, function ($entity) use($authChecker) { return $authChecker->isGranted('view', $entity); }); //If there are no matches return an empty array $answer['events'] = $result ? array_values($result) : []; return $answer; }
/** * Get all Filesystem entities. * * @View(serializerEnableMaxDepthChecks=true) * * @param Request $request * @param ParamFetcherInterface $paramFetcher * @return array|FOSView * @QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.") * @QueryParam(name="limit", requirements="\d+", default="20", description="How many notes to return.") * @QueryParam(name="order_by", nullable=true, array=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC") * @QueryParam(name="filters", nullable=true, array=true, description="Filter by fields. Must be an array ie. &filters[id]=3") * * @Security("has_role('ROLE_FILEMANAGER_LIST')") */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { try { $offset = $paramFetcher->get('offset'); $limit = $paramFetcher->get('limit'); $order_by = $paramFetcher->get('order_by'); $filters = !is_null($paramFetcher->get('filters')) ? $paramFetcher->get('filters') : array(); $em = $this->getDoctrine()->getManager(); /** @var FilesystemRepository $repository */ $repository = $em->getRepository('XxamFilemanagerBundle:Filesystem'); $entities = $repository->findBy($filters, $order_by, $limit, $offset); if ($entities) { //total: $total = $repository->getTotalcount($filters); $results = array(); /** @var Filesystem $entity */ foreach ($entities as $entity) { $results[] = $entity->toGridObject($request->getSession()->get('timezone')); } return array('filesystems' => $results, 'limit' => $limit, 'offset' => $offset, 'totalCount' => $total); } return FOSView::create('Not Found', Codes::HTTP_NO_CONTENT); } catch (\Exception $e) { return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR); } }
/** * List all prestasis. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing prestasis.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many prestasis to return.") * * @Annotations\View( * templateVar="prestasis" * ) * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getPrestasisAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ais_prestasi.prestasi.handler')->all($limit, $offset); }
/** * List all ArticleTypes. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing ArticleTypes.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many ArticleTypes to return.") * * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getArticletypesAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null === $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ojs_api.article_type.handler')->all($limit, $offset); }
/** * List all PublisherManager. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing PublisherManager.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many PublisherManager to return.") * * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getPublishermanagersAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null === $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ojs_api.publisher_manager.handler')->all($limit, $offset); }
/** * List all Boards. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing Boards.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many Boards to return.") * * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getBoardsAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null === $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ojs_api.journal_board.handler')->all($limit, $offset); }
/** * Get events for a user * * @ApiDoc( * resource = true, * description = "Get materials for a user.", * output="Ilios\CoreBundle\Classes\UserMaterial", * statusCodes = { * 200 = "List of user materials", * 204 = "No content. Nothing to list." * }, * tags = { * "beta" * } * ) * @QueryParam( * name="before", * nullable=true, * requirements="\d+", * description="Timestamp - all Materials before a date." * ) * @QueryParam( * name="after", * nullable=true, * requirements="\d+", * description="Timestamp - all Materials after a date." * ) * * @View(serializerEnableMaxDepthChecks=true) * * @param integer $id * * @return Response * * * @throws \Exception */ public function getAction($id, ParamFetcherInterface $paramFetcher) { $manager = $this->container->get('ilioscore.user.manager'); $user = $manager->findOneBy(['id' => $id]); if (!$user) { throw new NotFoundHttpException(sprintf('The user \'%s\' was not found.', $id)); } $authChecker = $this->get('security.authorization_checker'); if (!$authChecker->isGranted('view', $user)) { throw $this->createAccessDeniedException('Unauthorized access!'); } $criteria = []; $beforeTimestamp = $paramFetcher->get('before'); if (!is_null($beforeTimestamp)) { $criteria['before'] = DateTime::createFromFormat('U', $beforeTimestamp); } $afterTimestamp = $paramFetcher->get('after'); if (!is_null($afterTimestamp)) { $criteria['after'] = DateTime::createFromFormat('U', $afterTimestamp); } $materials = $manager->findMaterialsForUser($user->getId(), $criteria); //If there are no matches return an empty array $answer['userMaterials'] = $materials ? array_values($materials) : []; return $answer; }
/** * List all mahasiswa_profiles. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing mahasiswa_profiles.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many mahasiswa_profiles to return.") * * @Annotations\View( * templateVar="mahasiswa_profiles" * ) * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getMahasiswaProfilesAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ais_mahasiswa_profile.mahasiswa_profile.handler')->all($limit, $offset); }
/** * List all categories. * * @ApiDoc( * description = "Get the collection of categories.", * output = "PhpInk\Nami\CoreBundle\Util\Collection<PhpInk\Nami\CoreBundle\Model\CategoryInterface>", * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * @Annotations\QueryParam(name="orderBy", map=true, requirements="[a-zA-Z0-9-\.]+", description="Sort by fields") * @Annotations\QueryParam(name="filterBy", map=true, requirements="[a-zA-Z0-9-:\.\<\>\!\%+]+", description="Filters") * * ie: ?offset=2&limit=10&orderBy[name]=0&orderBy[locale]=en&filterBy[parent]=1 * * @param ParamFetcherInterface $paramFetcher Param fetcher service * * @return array */ public function getCategoriesTreeAction(ParamFetcherInterface $paramFetcher) { /** @var \PhpInk\Nami\CoreBundle\Repository\Core\CategoryRepositoryInterface $categoryRepo */ $categoryRepo = $this->getRepository(); $categories = $categoryRepo->getCategoryTreePaginated($this->getLoggedUser(), $paramFetcher->get('orderBy'), $paramFetcher->get('filterBy')); return $this->restView($categories); }
/** * List all comments * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many notes to return.") * * @Annotations\View() * * @param Request $request * @param ParamFetcherInterface $paramFetcher * * @return array */ public function getCommentsAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $start = null == $offset ? 0 : $offset + 1; $limit = $paramFetcher->get('limit'); $comments = $this->getDoctrine()->getRepository('TDomainBundle:Comment')->findAll(); return array('comments' => $comments, 'offset' => $offset, 'limit' => $limit); }
/** * REST GET list * * @QueryParam( * name="offset", * requirements="\d+", * nullable=true, * description="Starting from" * ) * @QueryParam( * name="limit", * requirements="\d+", * nullable=true, * description="Number of items" * ) * @ApiDoc( * description="Get all notifications", * resource=true * ) * * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return Response */ public function getAllAction(ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $start = null == $offset ? 0 : $offset + 1; $limit = $paramFetcher->get('limit'); $notifications = $this->notificationProvider->getAll($start, $limit); return new NotificationCollection($notifications, $offset, $limit); }
/** * Creates a log entry. * * @ApiDoc( * section="AbcLoggerBundle", * statusCodes = { * 204 = "Returned on success", * 400 = "Returned in case of a validation error" * } * ) * * @Post("/log/{application}") * * @RequestParam(name="level", requirements="(emergency|alert|critical|error|warning|notice|info|debug)", description="The log level", strict=true, nullable=false) * @RequestParam(name="message", description="The log message", strict=true, nullable=false) * @RequestParam(name="context", description="The context map", nullable=true) * * @param string $application The name of the client application * @param ParamFetcherInterface $paramFetcher * @return void */ public function logAction($application, ParamFetcherInterface $paramFetcher) { $level = $paramFetcher->get('level'); $message = $paramFetcher->get('message'); $context = $paramFetcher->get('context'); $this->getRegistry()->get($application)->log($level, $message, $context == null ? [] : $context); return null; }
/** * @Get("") * @ApiDoc( * section="Topics" * ) * * @QueryParam(name="page", description="Page, 0-indexed.", default=0, requirements="\d+") * @QueryParam(name="per_page", description="Elements per page. Maximum 1000.", default=10, requirements="\d+") * * @param ParamFetcherInterface $paramFetcher * @return PaginatedResource */ public function cgetAction(ParamFetcherInterface $paramFetcher) { $handler = $this->get('un.topic_handler'); $page = (int) $paramFetcher->get('page'); $perPage = (int) $paramFetcher->get('per_page'); $paginator = $handler->getPaginated($page, $perPage); return PaginatedResourceFactory::fromPaginator($paginator, $page); }
/** * Retrieves the list of tags (paginated) based on criteria. * * @ApiDoc( * resource=true, * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * * @QueryParam(name="page", requirements="\d+", default="1", description="Page for tag list pagination") * @QueryParam(name="count", requirements="\d+", default="10", description="Number of tags by page") * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled tags filter") * * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true) * * @param ParamFetcherInterface $paramFetcher * * @return PagerInterface */ public function getTagsAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $tagsPager */ $tagsPager = $this->tagManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $tagsPager; }
/** *@Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing offres.") *@Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many offres to return.") * * @param Request $request * @param ParamFetcherInterface $paramFetcher * @return type */ public function getLocationsAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $start = null == $offset ? 0 : $offset + 1; $limit = $paramFetcher->get('limit'); $locations = $this->getDoctrine()->getRepository('AppBundle:Location')->findAll(); return array_slice($locations, $start, $limit, true); }
/** * Retrieves the list of categories (paginated) based on criteria. * * @ApiDoc( * resource=true, * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * * @QueryParam(name="page", requirements="\d+", default="1", description="Page for category list pagination") * @QueryParam(name="count", requirements="\d+", default="10", description="Number of categories by page") * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled categories filter") * @QueryParam(name="context", requirements="\S+", nullable=true, strict=true, description="Context of categories") * * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true) * * @param ParamFetcherInterface $paramFetcher * * @return PagerInterface */ public function getCategoriesAction(ParamFetcherInterface $paramFetcher) { $page = $paramFetcher->get('page'); $count = $paramFetcher->get('count'); /** @var PagerInterface $categoriesPager */ $categoriesPager = $this->categoryManager->getPager($this->filterCriteria($paramFetcher), $page, $count); return $categoriesPager; }
/** * List all notes. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many notes to return.") * * @Annotations\View() * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getNotesAction(Request $request, ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $start = null == $offset ? 0 : $offset + 1; $limit = $paramFetcher->get('limit'); $notes = $this->getNoteManager()->fetch($start, $limit); return new NoteCollection($notes, $offset, $limit); }
/** * List all level with score per user. * * @ApiDoc( * resource = true, * description = "List all level with score per user.", * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing level.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="15", description="How many level to return.") * * @author Benjamin Brandt * @version 1.0 * @param string $user_name The name of the searched user. * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array list of searched level. */ public function getListAction($user_name, Request $request, ParamFetcherInterface $paramFetcher) { $user_name = $request->headers->get('name'); $accesstoken = $request->headers->get('accesstoken'); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('verbunden_blendoku.game.handler')->listGames($user_name, $accesstoken, $offset, $limit); }
/** * @ApiDoc( * description="Obtener todos los usuarios", * input={"name"="Usuario", "class"="ApiBundle\Form\UsuarioType"}, * output={"class"="BaseBundle/Entity/Usuario"} * ) * @QueryParam(name="username", description="Nombre de Usuario.") * @QueryParam(name="password", description="Contrase{a del Usuario.") * @Get("/getUsuarios") */ public function getUsuariosAction(ParamFetcherInterface $paramFetcher) { $usuario = $this->getDoctrine()->getManager()->getRepository('BaseBundle:Usuario')->findBy(array('username' => $paramFetcher->get('username')))[0]; if ($this->get('security.password_encoder')->isPasswordValid($usuario, $paramFetcher->get('password'))) { return $this->getDoctrine()->getManager()->getRepository('BaseBundle:Usuario')->findAll(); } else { throw new BadRequestHttpException("Usuario y contraseña incorrectos."); } }
/** * * @ApiDoc( * resource=true, * description="Returns a collection of Tasks", * section="Tasks", * requirements={ * {"name"="limit", "dataType"="integer", "requirement"="\d+", "description"="the max number of records to return"} * }, * parameters={ * {"name"="limit", "dataType"="integer", "required"=true, "description"="the max number of records to return"}, * {"name"="offset", "dataType"="integer", "required"=false, "description"="the record number to start results at"} * } * ) * * @param $project * * @QueryParam(name="limit", requirements="\d+", default="10", description="our limit") * @QueryParam(name="offset", requirements="\d+", nullable=true, default="0", description="our offset") * * @return mixed */ public function getTasksAction(ParamFetcherInterface $paramFetcher, Project $project) { if ($project->getUser() != $this->getUser()) { throw $this->createAccessDeniedException(); } $limit = $paramFetcher->get('limit'); $offset = $paramFetcher->get('offset'); return $this->getHandler()->all($project, $limit, $offset); }
/** * List all servers. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing servers.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many servers to return.") * * @Annotations\View() * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getServersAction(Request $request, ParamFetcherInterface $paramFetcher) { $session = $request->getSession(); $offset = $paramFetcher->get('offset'); $start = null == $offset ? 0 : $offset + 1; $limit = $paramFetcher->get('limit'); $servers = $session->get(self::SESSION_CONTEXT_SERVER, array()); $servers = array_slice($servers, $start, $limit, true); return new ServerCollection($servers, $offset, $limit); }
/** * List all ArticleTypes. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing ArticleTypes.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many ArticleTypes to return.") * * * @param Request $request the request object * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getArticletypesAction(Request $request, ParamFetcherInterface $paramFetcher) { if (!$this->isGranted('VIEW', new ArticleTypes())) { throw new AccessDeniedHttpException(); } $offset = $paramFetcher->get('offset'); $offset = null === $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ojs_api.article_type.handler')->all($limit, $offset); }
/** * List all Announcements. * * @ApiDoc( * resource = true, * statusCodes = { * 200 = "Returned when successful" * } * ) * * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing Announcements.") * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many Announcements to return.") * * * @param ParamFetcherInterface $paramFetcher param fetcher service * * @return array */ public function getAnnouncementsAction(ParamFetcherInterface $paramFetcher) { $offset = $paramFetcher->get('offset'); $offset = null === $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); return $this->container->get('ojs_api.announcement.handler')->all($limit, $offset); }