当前位置: 首页>>代码示例>>PHP>>正文


PHP ParamFetcher::all方法代码示例

本文整理汇总了PHP中FOS\RestBundle\Request\ParamFetcher::all方法的典型用法代码示例。如果您正苦于以下问题:PHP ParamFetcher::all方法的具体用法?PHP ParamFetcher::all怎么用?PHP ParamFetcher::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FOS\RestBundle\Request\ParamFetcher的用法示例。


在下文中一共展示了ParamFetcher::all方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cgetAction

 /**
  * @View(serializerGroups={"list"}, serializerEnableMaxDepthChecks=true)
  * @QueryParam(name="page", requirements="\d+", default="1")
  * @QueryParam(name="limit", requirements="\d+", default="7")
  *
  * @param Request $request
  * @param ParamFetcher $paramFetcher
  * @return \FOS\RestBundle\View\View
  */
 public function cgetAction(Request $request, ParamFetcher $paramFetcher)
 {
     $params = array_intersect_assoc($paramFetcher->all(), $request->query->all());
     /** @var Pagerfanta $pager */
     $pager = $this->getHandler()->cget($paramFetcher->all(), array_diff_assoc($request->query->all(), $params));
     $view = RestView::create(iterator_to_array($pager->getCurrentPageResults()), Codes::HTTP_OK, array('X-Current-Page' => $pager->getCurrentPage(), 'X-Total-Count' => $pager->getNbResults(), 'X-Total-Pages' => $pager->getNbPages(), 'X-Per-Page' => $pager->getMaxPerPage()));
     $context = SerializationContext::create();
     $context->enableMaxDepthChecks();
     $context->setGroups(array('list'));
     $view->setSerializationContext($context);
     return $view;
 }
开发者ID:bixlabs,项目名称:concepto-sises,代码行数:21,代码来源:RestController.php

示例2: paginate

 /**
  * Paginate query results using knp paginator bundle
  * 
  * @param ParamFetcher $paramFetcher
  * @param Query $query
  * @param string $sortAlias
  * @return Hal
  */
 protected function paginate(ParamFetcher $paramFetcher, $query, $sortAlias)
 {
     $request = $this->getRequest();
     $params = $paramFetcher->all() + $this->getPagingParams();
     //alternative page start index support
     if (!empty($params['pageStartIndex'])) {
         $page = abs(round($params['pageStartIndex'] / $params['pageSize'])) + 1;
     }
     $aliasPrefix = $sortAlias . '.';
     //paginator
     $paginator = $this->get('knp_paginator');
     //sort fields resource values to entity fields conversion
     if (!empty($params['sortBy']) && substr($params['sortBy'], 0, 2) != $aliasPrefix) {
         $_GET['sortBy'] = $aliasPrefix . $params['sortBy'];
         //set default sortBy if none is set
     } else {
         //$_GET['sortBy'] = $aliasPrefix . 'id';
     }
     if (empty($params['sortOrder'])) {
         //$_GET['sortOrder'] = 'asc';
     }
     $items = $paginator->paginate($query, $params['page'], $params['pageSize']);
     $paginationData = $items->getPaginationData();
     //root data
     $rootArr = array('totalCount' => $paginationData['totalCount'], 'pageCount' => $paginationData['pageCount'], 'pageSize' => $paginationData['numItemsPerPage'], 'currentPage' => intval($paginationData['current']), 'currentPageItemCount' => $paginationData['currentItemCount']);
     $entityName = $this->getEntityNameFromResourceObject($items);
     $hal = new Hal($request->getUri(), $rootArr, $entityName);
     //paging links
     $this->addPagingLinks($hal, $paginationData);
     //collection output
     foreach ($items as $item) {
         $hal->addResource($this->getResourceName(), new Hal($this->getResourceUrl($item, $params), $item));
     }
     return $hal;
 }
开发者ID:sparrowDom,项目名称:pigapi,代码行数:43,代码来源:Controller.php

示例3: getPlayersAction

 /**
  * @ApiDoc(resource=true)
  * @QueryParam(name="limit", default="50")
  * @QueryParam(name="page", default="1")
  * @QueryParam(name="position", default="")
  * @QueryParam(name="sort", default="ASC")
  * @QueryParam(name="nflTeam", default="")
  */
 public function getPlayersAction(ParamFetcher $paramFetcher)
 {
     $queryBuilder = $this->getDoctrine()->getManager()->createQueryBuilder();
     $params = $paramFetcher->all();
     $sort = array('key' => 'name', 'value' => $params['sort']);
     unset($params['sort']);
     $queryBuilder = $this->get('app.queryparamservice')->buildSelectQuery($queryBuilder, $params, 'Player', $sort);
     $players = $queryBuilder->getQuery()->execute();
     $view = $this->view($players, 200);
     return $this->handleView($view);
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:19,代码来源:PlayerController.php

示例4: getLeagueplayersAction

 /**
  * @ApiDoc(resource=true)
  * @param ParamFetcher $paramFetcher
  * @QueryParam(name="league", default="")
  * @QueryParam(name="limit", default="50")
  * @QueryParam(name="page", default="1")
  * @QueryParam(name="position", default="")
  * @QueryParam(name="sort", default="ASC")
  * @QueryParam(name="team", default="")
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getLeagueplayersAction(ParamFetcher $paramFetcher)
 {
     $params = $paramFetcher->all();
     $sort = $params['sort'];
     unset($params['sort']);
     $queryBuilder = $this->getDoctrine()->getManager()->createQueryBuilder();
     $builder = $this->get('app.queryparamservice')->buildSelectQuery($queryBuilder, $params, 'League_Player', array(), 'player', array('position' => $params['position']));
     $leaguePlayers = $builder->join('DraftBundle\\Entity\\Player', 'p', null, " where c.player = p.id")->orderBy('p.name', $sort)->getQuery()->execute();
     $view = $this->view($leaguePlayers, 200);
     return $this->handleView($view);
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:22,代码来源:LeagueplayerController.php

示例5: getRestaurantsAction

 /**
  * @ApiDoc(
  *  resource=true,
  *  description="Search restaurant"
  * )
  *
  * @QueryParam(name="q", description="Global Query")
  * @QueryParam(name="name", description="Name")
  * @QueryParam(name="address", description="Address.")
  * @QueryParam(name="zip_code", description="Zip code.")
  * @QueryParam(name="city", description="City.")
  *
  * @QueryParam(name="page", requirements="\d+", default="1", description="Set current page")
  * @QueryParam(name="per_page", requirements="\d+", default="10", description="Number of restaurants returned per page")
  *
  * @View()
  *
  * @param ParamFetcher $paramFetcher Paramfetcher
  */
 public function getRestaurantsAction(ParamFetcher $paramFetcher)
 {
     $parameters = $paramFetcher->all();
     $restaurants = [];
     $count = 0;
     $restaurantsCursor = $this->get('doctrine_mongodb')->getRepository('FdbcRestoCoreBundle:Restaurant')->getRestaurants($parameters, $parameters['per_page'], $parameters['page'] * $parameters['per_page'] - $parameters['per_page']);
     foreach ($restaurantsCursor as $restaurant) {
         $restaurants[] = $restaurant;
         $count++;
     }
     return ['total' => $count, 'data' => $restaurants];
 }
开发者ID:fernandodbc,项目名称:resto-gastro-api,代码行数:31,代码来源:RestaurantController.php

示例6: getLeagueDraftordersAction

 /**
  * @ApiDoc(resource=true)
  * @QueryParam(name="team", default="")
  * @QueryParam(name="round", default="")
  * @ApiDoc(resource=true)
  */
 public function getLeagueDraftordersAction($league, ParamFetcher $paramFetcher)
 {
     $league = $this->getDoctrine()->getRepository('DraftBundle:League')->find($league);
     if (empty($league)) {
         return $this->handleView(View::create(null, 404));
     }
     $queryBuilder = $this->getDoctrine()->getManager()->createQueryBuilder();
     $params = $paramFetcher->all();
     $queryBuilder = $this->get('app.queryparamservice')->buildSelectQuery($queryBuilder, $params, 'DraftOrder');
     $draftOrders = $queryBuilder->getQuery()->execute();
     return $this->handleView(View::create($draftOrders));
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:18,代码来源:LeagueDraftOrderController.php

示例7: getTeamsAction

 /**
  * @ApiDoc(resource=true)
  * @return \Symfony\Component\HttpFoundation\Response
  * @Rest\QueryParam(name="league", default="")
  * @Rest\QueryParam(name="sortname", default="ASC")
  * @Rest\QueryParam(name="limit", default="50")
  * @Rest\QueryParam(name="page", default="1")
  */
 public function getTeamsAction(ParamFetcher $paramFetcher)
 {
     $sort = array("key" => "name", "value" => $paramFetcher->get('sortname'));
     $params = $paramFetcher->all();
     unset($params['sortname']);
     $queryBuilder = $this->getDoctrine()->getManager()->createQueryBuilder();
     $builder = $this->get('app.queryparamservice')->buildSelectQuery($queryBuilder, $params, 'Team', array(), '', array());
     $builder->orderBy('c.name', 'ASC');
     $teams = $builder->getQuery()->execute();
     $view = $this->view($teams, 200);
     return $this->handleView($view);
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:20,代码来源:TeamController.php

示例8: fetchParameters

 /**
  * Fetch parameters from URI.
  *
  * @param \FOS\RestBundle\Request\ParamFetcher $paramFetcher
  * @return array of options
  */
 private function fetchParameters(ParamFetcher $paramFetcher)
 {
     $options = array();
     foreach ($paramFetcher->all() as $criterionName => $criterionValue) {
         // If the param is a date then create a datetime object
         if (false !== strpos(strtolower($criterionName), 'date')) {
             $options[$criterionName] = new \DateTime($criterionValue);
         } else {
             $options[$criterionName] = $criterionValue;
         }
     }
     return $options;
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:19,代码来源:CurrencyRateController.php

示例9: getLeaguesAction

 /**
  * @return \Symfony\Component\HttpFoundation\Response
  * @QueryParam(name="user", default="")
  * @ApiDoc(resource=true)
  */
 public function getLeaguesAction(ParamFetcher $paramFetcher)
 {
     $queryBuilder = $this->getDoctrine()->getManager()->createQueryBuilder();
     $params = $paramFetcher->all();
     $user = $params['user'];
     unset($params['user']);
     $builder = $this->get('app.queryparamservice')->buildSelectQuery($queryBuilder, $params, 'League');
     if ($user) {
         $builder->join('DraftBundle\\Entity\\Team', 't', null, 'where t.league = c.id');
         $builder->join('DraftBundle\\Entity\\User', 'u', null, 'where t.user = u.id');
     }
     $leagues = $builder->getQuery()->execute();
     $view = $this->view($leagues, 200);
     return $this->handleView($view);
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:20,代码来源:LeagueController.php

示例10: paramFetcherFilters

 protected function paramFetcherFilters(ParamFetcher $paramFetcher)
 {
     $filters = [];
     foreach ($paramFetcher->all() as $name => $value) {
         if ($value !== null && $value != '' && preg_match("/^(period)+([a-zA-Z]+)+(Begin|End)/", $name, $m)) {
             $filters[lcfirst($m[2])][strtolower($m[3])] = $value;
         } elseif ($value !== null && $value != '' && preg_match("/^(filter)+([a-zA-Z]+)/", $name, $m)) {
             $filters[lcfirst($m[2])] = $value;
         } elseif ($value !== null && $value != '' && is_numeric($value) && preg_match("/^(lastDays)+([a-zA-Z]+)/", $name, $m)) {
             $dt = new \DateTime();
             if ($value > 1) {
                 $dt->sub(new \DateInterval('P' . ($value - 1) . 'D'));
             }
             $filters[lcfirst($m[2])]['begin'] = $dt->format('Y-m-d');
         }
     }
     return $filters;
 }
开发者ID:coresite,项目名称:corebundle,代码行数:18,代码来源:ParamFetcherController.php

示例11: postPhotoAction

 /**
  * @ApiDoc(description="Uploads photo with tags.")
  *
  * @Rest\FileParam(name="image", image=true, description="Image to upload.")
  * @Rest\RequestParam(name="tags", requirements=".+", nullable=false, map=true, description="Tags that associates photo.")
  * @Rest\View()
  */
 public function postPhotoAction(ParamFetcher $paramFetcher, array $tags)
 {
     $em = $this->getDoctrine()->getManager();
     $photo = new Photo();
     $form = $this->createForm(PhotoType::class, $photo);
     if ($tags) {
         $tags = $em->getRepository('TestTaskTagsBundle:Tag')->findOrCreateByTitles($tags);
     }
     $form->submit($paramFetcher->all());
     if (!$form->isValid()) {
         return $form->getErrors();
     }
     foreach ($tags as $tag) {
         $photo->addTag($tag);
     }
     $em->persist($photo);
     $em->flush();
     return array('photo' => $photo);
 }
开发者ID:Koc,项目名称:stfalcon-test-task,代码行数:26,代码来源:ApiController.php

示例12: getUsersSearchAction

 /**
 * Search for users on Twitter.
 *
 * Example Request
 * ===============
 *
 *      GET /api/v1/p/campaignchain/channel-twitter/users/search?q=ordnas&location=42
 *
 * Example Response
 * ================
 *
     [
    {
        "insert_name":"ordnas",
        "display_name":"Sandro Groganz",
        "search_key":"ordnas Sandro Groganz",
        "image":"http:\/\/pbs.twimg.com\/profile_images\/669150051386683392\/VYPoxcqJ_normal.jpg"
    },
    {
        "insert_name":"Ordnas69",
        "display_name":"Sandro Summa",
        "search_key":"Ordnas69 Sandro Summa",
        "image":"http:\/\/pbs.twimg.com\
        /profile_images\/688442716074676225\/z5A7CmQs_normal.jpg"
    },
    {
        "insert_name":"sssaannddrrooo",
        "display_name":"Ordnas",
        "search_key":"sssaannddrrooo Ordnas",
        "image":"http:\/\/pbs.twimg.com\/profile_images\/667602635013361664
        \/s0qPns5T_normal.jpg"
    },
    {
        "insert_name":"OrdnasPB",
        "display_name":"Sandro",
        "search_key":"OrdnasPB Sandro",
        "image":"http:\/\/pbs.twimg.com\/profile_images\/711797319553961984\/MvwFTuwt_normal.jpg"
    },
    {
        "insert_name":"sandalagoa",
        "display_name":"Ordnas Aiam",
        "search_key":"sandalagoa Ordnas Aiam",
        "image":"http:\/\/pbs
        .twimg.com\/profile_images\/1550555986\/308999_10150323188574382_614399381_7994968_909345970_n_normal.jpg"
    },
    {
        "insert_name":"ordnas24",
        "display_name":"Sandro Bezerra",
        "search_key":"ordnas24 Sandro Bezerra",
        "image":"http:\/\/pbs.twimg.com\/profile_images\/544808863116304384\/IxcjtzZk_normal.jpeg"
    }
     ]
 *
 * @ApiDoc(
 *  section="Packages: Twitter"
 * )
 *
 * @REST\QueryParam(
 *      name="q",
 *      map=false,
 *      requirements="[A-Za-z0-9][A-Za-z0-9_.-]*",
 *      description="The search query to run against people search."
 *  )
 *
 * @REST\QueryParam(
 *      name="location",
 *      map=false,
 *      requirements="\d+",
 *      description="The ID of a CampaignChain Location you'd like to use to connect with Twitter."
 *  )
 */
 public function getUsersSearchAction(ParamFetcher $paramFetcher)
 {
     try {
         $params = $paramFetcher->all();
         /** @var LocationService $locationService */
         $locationService = $this->get('campaignchain.core.location');
         $location = $locationService->getLocation($params['location']);
         /** @var TwitterClient $channelRESTService */
         $channelRESTService = $this->get('campaignchain.channel.twitter.rest.client');
         $connection = $channelRESTService->connectByLocation($location);
         $request = $connection->get('users/search.json?q=' . $params['q'] . '&count=6&include_entities=false');
         $response = $request->send()->json();
         foreach ($response as $user) {
             $data[] = array('insert_name' => $user['screen_name'], 'display_name' => $user['name'], 'search_key' => $user['screen_name'] . ' ' . $user['name'], 'image' => $user['profile_image_url']);
         }
         return $this->response($data);
     } catch (\Exception $e) {
         return $this->errorResponse($e->getMessage(), $e->getCode());
     }
 }
开发者ID:campaignchain,项目名称:channel-twitter,代码行数:91,代码来源:ChannelController.php

示例13: postStoreAction

 /**
  * Creates a new store
  * 
  * @ApiDoc(
  * resource=true,
  * description="Post a new store",
  * statusCodes={
  *    200="Successful",
  *    500="An error occured"
  * },
  * input="StoreBundle\Form\StoreType"
  * )
  * 
  * @param ParamFetcher $paramFetcher ParamFetcher
  * 
  */
 public function postStoreAction(ParamFetcher $paramFetcher)
 {
     $entity = new Store();
     $form = $this->createForm(StoreType::class, $entity);
     $form->submit($paramFetcher->all());
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
     }
     return array('form' => $form);
 }
开发者ID:hakim95,项目名称:storeApi,代码行数:28,代码来源:StoreController.php

示例14: getCampaignsAction

 /**
 * Get a list of Campaigns.
 *
 * Example Request
 * ===============
 *
 *      GET /api/v1/campaigns?fromNow[]=ongoing&moduleUri[]=campaignchain/campaign-scheduled/campaignchain-scheduled&status[]=open
 *
 * Example Response
 * ================
 *
     [
    {
        "id": 2,
        "timezone": "America/Paramaribo",
        "hasRelativeDates": false,
        "name": "Company Anniversary",
        "startDate": "2015-06-10T22:01:32+0000",
        "endDate": "2015-12-21T05:04:27+0000",
        "status": "open",
        "createdDate": "2015-11-26T11:08:29+0000"
    },
    {
        "id": 3,
        "timezone": "Asia/Tashkent",
        "hasRelativeDates": false,
        "name": "Customer Win Story",
        "startDate": "2015-09-28T07:02:39+0000",
        "endDate": "2016-04-18T01:44:23+0000",
        "status": "open",
        "createdDate": "2015-11-26T11:08:29+0000"
    }
     ]
 *
 * @ApiDoc(
 *  section="Core"
 * )
 *
 * @REST\QueryParam(
 *      name="fromNow",
 *      map=true,
 *      requirements="(done|ongoing|upcoming)",
 *      description="Filters per start and end date, options: 'upcoming' (start date is after now), 'ongoing' (start date is before and end date after now), 'done' (end date is before now)."
 * )
 * @REST\QueryParam(
 *      name="status",
 *      map=true,
 *      requirements="(open|closed|paused|background process|interaction required)",
 *      description="Workflow status of a campaign."
 * )
 * @REST\QueryParam(
 *      name="moduleUri",
 *      map=true,
 *      requirements="[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*\/[A-Za-z0-9][A-Za-z0-9_.-]*",
 *      description="The module URI of a campaign module, e.g. campaignchain/campaign-scheduled/campaignchain-scheduled."
 *  )
 */
 public function getCampaignsAction(ParamFetcher $paramFetcher)
 {
     try {
         $params = $paramFetcher->all();
         $qb = $this->getQueryBuilder();
         $qb->select('c');
         $qb->from('CampaignChain\\CoreBundle\\Entity\\Campaign', 'c');
         if ($params['moduleUri']) {
             $qb->from('CampaignChain\\CoreBundle\\Entity\\Bundle', 'b');
             $qb->from('CampaignChain\\CoreBundle\\Entity\\Module', 'm');
             $qb->andWhere('b.id = m.bundle');
             $qb->andWhere('c.campaignModule = m.id');
             foreach ($params['moduleUri'] as $key => $moduleUri) {
                 $moduleUriParts = explode('/', $moduleUri);
                 $vendor = $moduleUriParts[0];
                 $project = $moduleUriParts[1];
                 $identifier = $moduleUriParts[2];
                 $moduleUriQuery[] = '(b.name = :package' . $key . ' AND ' . 'm.identifier = :identifier' . $key . ')';
                 $qb->setParameter('package' . $key, $vendor . '/' . $project);
                 $qb->setParameter('identifier' . $key, $identifier);
             }
             $qb->andWhere(implode(' OR ', $moduleUriQuery));
         }
         if ($params['fromNow']) {
             foreach ($params['fromNow'] as $fromNow) {
                 switch ($fromNow) {
                     case 'done':
                         $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate < CURRENT_TIMESTAMP())';
                         break;
                     case 'ongoing':
                         $fromNowQuery[] = '(c.startDate < CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
                         break;
                     case 'upcoming':
                         $fromNowQuery[] = '(c.startDate > CURRENT_TIMESTAMP() AND c.endDate > CURRENT_TIMESTAMP())';
                         break;
                 }
             }
             $qb->andWhere(implode(' OR ', $fromNowQuery));
         }
         if ($params['status']) {
             foreach ($params['status'] as $key => $status) {
                 $statusQuery[] = 'c.status = :status' . $key;
                 $qb->setParameter('status' . $key, $status);
//.........这里部分代码省略.........
开发者ID:CampaignChain,项目名称:core,代码行数:101,代码来源:RootController.php


注:本文中的FOS\RestBundle\Request\ParamFetcher::all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。