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


PHP Document::addMeta方法代码示例

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


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

示例1: search

 /**
  * @param string $status
  * @param string $title
  * @param string $description
  * @param string $type
  * @param string $priority
  *
  * @return Document
  */
 public function search($status = null, $title = null, $description = null, $type = null, $priority = null)
 {
     $results = $this->service->search($status, $title, $description, $type, $priority);
     $collection = (new Collection($results, $this->serializer))->with(['author', 'comments']);
     $document = new Document($collection);
     $document->addMeta('total', count($results));
     return $document;
 }
开发者ID:kleijnweb,项目名称:swagger-bundle-example,代码行数:17,代码来源:TicketController.php

示例2: generateMetaData

 /** @return  void */
 protected function generateMetaData(ResponseInterface $response, Document $document)
 {
     if (is_null($this->metaDataGenerator)) {
         return;
     }
     $metaData = call_user_func($this->metaDataGenerator, $response);
     foreach ($metaData as $key => $value) {
         $document->addMeta($key, $value);
     }
 }
开发者ID:WebspotCode,项目名称:SpotApi,代码行数:11,代码来源:AbstractSerializingGenerator.php

示例3: toApplicationOverviewData

 /**
  * Convert's the passed DTOs into a JSON-API document representation.
  *
  * @param \AppserverIo\Collections\CollectionInterface $applications The application DTOs to convert
  *
  * @return Tobscure\JsonApi\Document The JSON-API document representation
  */
 protected function toApplicationOverviewData(CollectionInterface $applications)
 {
     // create a new collection of naming directories
     $collection = new Collection($applications->toArray(), new ApplicationSerializer());
     // create a new JSON-API document with that collection as the data
     $document = new Document($collection);
     // add metadata and links
     $document->addMeta('total', count($applications));
     // return the JSON-API representation
     return $document;
 }
开发者ID:appserver-io-apps,项目名称:api,代码行数:18,代码来源:ApplicationAssembler.php

示例4: toVirtualHostOverviewData

 /**
  * Convert's the passed virtual host DTOs into a JSON-API document representation.
  *
  * @param \AppserverIo\Collections\CollectionInterface $virtualHosts The virtual host DTOs to convert
  *
  * @return Tobscure\JsonApi\Document The JSON-API document representation
  */
 protected function toVirtualHostOverviewData(CollectionInterface $virtualHosts)
 {
     // create a new collection of naming directories
     $collection = new Collection($virtualHosts->toArray(), new VirtualHostSerializer());
     // create a new JSON-API document with that collection as the data
     $document = new Document($collection);
     // add metadata and links
     $document->addMeta('total', count($virtualHosts));
     // return the stdClass representation of the naming directories
     return $document;
 }
开发者ID:appserver-io-apps,项目名称:api,代码行数:18,代码来源:VirtualHostAssembler.php

示例5: toPersistenceUnitOverviewData

 /**
  * Convert's the passed persistence unit DTOs into a JSON-API document representation.
  *
  * @param \AppserverIo\Collections\CollectionInterface $persistenceUnits The persistence unit DTOs to convert
  *
  * @return Tobscure\JsonApi\Document The JSON-API document representation
  */
 public function toPersistenceUnitOverviewData(CollectionInterface $persistenceUnits)
 {
     // create a new collection of naming directories
     $collection = new Collection($persistenceUnits, new PersistenceUnitSerializer());
     // create a new JSON-API document with that collection as the data
     $document = new Document($collection);
     // add metadata and links
     $document->addMeta('total', count($persistenceUnits));
     // return the stdClass representation of the naming directories
     return $document;
 }
开发者ID:appserver-io-apps,项目名称:api,代码行数:18,代码来源:PersistenceUnitAssembler.php

示例6: processAction

 public function processAction($args)
 {
     $document = new Document();
     $element = NULL;
     $meta = array();
     try {
         switch ($args['action']) {
             case "init_repository":
                 $this->initRepository($args['psw']);
                 $session = $this->getSession();
                 $element = new Resource($session, new SessionSerializer());
                 break;
             case "log_in":
                 $this->logIn($args['psw']);
                 $session = $this->getSession();
                 $element = new Resource($session, new SessionSerializer());
                 break;
             case "log_out":
                 $this->logOut();
                 $session = $this->getSession();
                 $element = new Resource($session, new SessionSerializer());
                 break;
             case "get_session":
                 $session = $this->getSession();
                 $element = new Resource($session, new SessionSerializer());
                 break;
             case "get_post":
                 $postId = isset($args['id']) ? $args['id'] : NULL;
                 $post = $this->getPost($postId);
                 $element = (new Resource($post, new PostSerializer()))->fields(['tags']);
                 break;
             case "get_posts":
                 $parameters = new Parameters($args);
                 $sort = $parameters->getSort();
                 if ($sort == NULL) {
                     $sort = array();
                 }
                 $limit = $parameters->getLimit();
                 if ($limit == NULL) {
                     $limit = -1;
                 }
                 $offset = $parameters->getOffset();
                 if ($offset == NULL) {
                     $offset = 0;
                 }
                 $posts = $this->getPosts($sort, $limit, $offset);
                 $element = (new Collection($posts, new PostSerializer()))->fields(['tags']);
                 break;
             case "publish_post":
                 $id = $this->publishPost($args['title'], $args['body'], $args['tags'], $args['draft'], $args['token']);
                 $element = new Resource(new stdClass(), new ResultSerializer());
                 $document->addMeta("id", $id);
                 break;
             case "update_post":
                 $id = $this->updatePost($args['id'], $args['title'], $args['body'], $args['tags'], $args['draft'], $args['token']);
                 $element = new Resource(new stdClass(), new ResultSerializer());
                 $document->addMeta("id", $id);
                 break;
             case "delete_post":
                 $this->deletePost($args['id'], $args['token']);
                 $element = new Resource(new stdClass(), new ResultSerializer());
                 break;
             default:
                 throw new Exception("unknown action " . $args['action'], self::EBL_ERROR_BADREQUEST);
                 break;
         }
     } catch (Exception $e) {
         http_response_code($e->getCode());
         $document->setErrors(array(array("message" => $e->getMessage())));
     }
     if ($element != NULL) {
         $document->setData($element);
     }
     echo json_encode($document->toArray());
 }
开发者ID:alessandrofrancesconi,项目名称:ebl,代码行数:75,代码来源:data.php


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