/**
  * 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);
 }
Example #3
0
 /**
  * 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);
 }
 /**
  * @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 [];
 }
 /**
  * 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);
 }
 public function testMissingParamFetchers()
 {
     $data = new CollectionRepresentation([new OffsetTestClass()]);
     $this->paramFetcher->method('get')->willThrowException(new InvalidArgumentException());
     $result = $this->getDecorator()->decorate(new ParameterBag(['paramFetcher' => $this->paramFetcher, '_route' => true]), $data);
     $this->assertEquals($data, $result);
 }
Example #8
0
 /**
  * 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;
 }
 /**
  * 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 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);
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 public function testCollectionResponse()
 {
     $data = new CollectionRepresentation([new PaginatedTestClass()]);
     $this->paramFetcher->method('get')->willReturn(7);
     $result = $this->getDecorator()->decorate(new ParameterBag(['paramFetcher' => $this->paramFetcher, '_route' => true]), $data);
     $this->assertInstanceOf(PaginatedRepresentation::class, $result);
     $this->assertEquals($data, $result->getInline());
 }
Example #21
0
 /**
  * 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);
 }
 /**
  *@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);
 }
Example #23
0
 /**
  * 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);
 }
Example #24
0
 /**
  * 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);
 }
 /**
  * Get the list of articles
  *
  * @param ParamFetcher $paramFetcher
  * @param string $page integer with the page number (requires param_fetcher_listener: force)
  * @return array data
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview.")
  * @ApiDoc()
  */
 public function getArticlesAction(ParamFetcherInterface $paramFetcher)
 {
     $page = $paramFetcher->get('page');
     $articles = array('bim', 'bam', 'bingo');
     $data = new HelloResponse($articles, $page);
     $view = new View($data);
     $view->setTemplate('LiipHelloBundle:Rest:getArticles.html.twig');
     return $this->get('fos_rest.view_handler')->handle($view);
 }
Example #26
0
 /**
  * @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.");
     }
 }
 /**
  * @Rest\Get("/")
  * @Rest\QueryParam(
  *  name="user_name",
  *  key=null,
  *  requirements=".+",
  *  default=null,
  *  description="The user name of the user to get.",
  *  strict=true,
  *  array=false,
  *  nullable=false
  * )
  * @Rest\View()
  *
  * @param ParamFetcherInterface $params
  * @return View
  * @throws HttpException
  */
 public function getByUserNameAction(ParamFetcherInterface $params)
 {
     $userName = $params->get('user_name');
     $user = $this->userService->getUserByUserName($userName);
     if ($user == null) {
         throw new NotFoundHttpException("User with user name '{$userName}' not found.");
     }
     return $this->viewBuilder->setDocument($user)->setVersion()->setLocation(static::BASE_ROUTE . $user->getId())->build();
 }
 /**
  *
  * @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);
 }
Example #29
0
 /**
  * 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);
 }
Example #30
-1
 /**
  * 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);
 }