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


PHP Service::loadAllDocumentFields方法代码示例

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


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

示例1: getDocumentSnippetById

 /**
  * @param $id
  * @throws \Exception
  */
 public function getDocumentSnippetById($id)
 {
     try {
         $snippet = Document::getById($id);
         if ($snippet instanceof Document\Snippet) {
             // load all data (eg. href, snippet, ... which are lazy loaded)
             Document\Service::loadAllDocumentFields($snippet);
             $className = Webservice\Data\Mapper::findWebserviceClass($snippet, "out");
             $apiSnippet = Webservice\Data\Mapper::map($snippet, $className, "out");
             return $apiSnippet;
         }
         throw new \Exception("Document Snippet with given ID (" . $id . ") does not exist.");
     } catch (\Exception $e) {
         \Logger::error($e);
         throw $e;
     }
 }
开发者ID:pawansgi92,项目名称:pimcore2,代码行数:21,代码来源:Service.php

示例2: loadAllFields

 /**
  * @static
  * @param ElementInterface $element
  * @return ElementInterface
  */
 public static function loadAllFields(ElementInterface $element)
 {
     if ($element instanceof Document) {
         Document\Service::loadAllDocumentFields($element);
     } else {
         if ($element instanceof Object\Concrete) {
             Object\Service::loadAllObjectFields($element);
         } else {
             if ($element instanceof Asset) {
                 Asset\Service::loadAllFields($element);
             }
         }
     }
     return $element;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:20,代码来源:Service.php

示例3: documentAction

 /** end point for document related data.
  * - get document by id
  *      GET http://[YOUR-DOMAIN]/webservice/rest/document/id/1281?apikey=[API-KEY]
  *      returns json-encoded document data.
  * - delete document by id
  *      DELETE http://[YOUR-DOMAIN]/webservice/rest/document/id/1281?apikey=[API-KEY]
  *      returns json encoded success value
  * - create document
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/document?apikey=[API-KEY]
  *      body: json-encoded document data in the same format as returned by get document by id
  *              but with missing id field or id set to 0
  *      returns json encoded document id
  * - update document
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/document?apikey=[API-KEY]
  *      body: same as for create document but with object id
  *      returns json encoded success value
  * @throws \Exception
  */
 public function documentAction()
 {
     $id = $this->getParam("id");
     $success = false;
     try {
         if ($this->isGet()) {
             $doc = Document::getById($id);
             if (!$doc) {
                 $this->encoder->encode(array("success" => false, "msg" => "Document does not exist", "code" => self::ELEMENT_DOES_NOT_EXIST));
                 return;
             }
             $this->checkPermission($doc, "get");
             if ($doc) {
                 $type = $doc->getType();
                 $getter = "getDocument" . ucfirst($type) . "ById";
                 if (method_exists($this->service, $getter)) {
                     $object = $this->service->{$getter}($id);
                 } else {
                     // check if the getter is implemented by a plugin
                     $class = "\\Pimcore\\Model\\Webservice\\Data\\Document\\" . ucfirst($type) . "\\Out";
                     if (Tool::classExists($class)) {
                         Document\Service::loadAllDocumentFields($doc);
                         $object = Webservice\Data\Mapper::map($doc, $class, "out");
                     } else {
                         throw new \Exception("unknown type");
                     }
                 }
             }
             if (!$object) {
                 throw new \Exception("could not find document");
             }
             @$this->encoder->encode(array("success" => true, "data" => $object));
             return;
         } else {
             if ($this->isDelete()) {
                 $doc = Document::getById($id);
                 if ($doc) {
                     $this->checkPermission($doc, "delete");
                 }
                 $success = $this->service->deleteDocument($id);
                 $this->encoder->encode(array("success" => $success));
                 return;
             } else {
                 if ($this->isPost() || $this->isPut()) {
                     $data = file_get_contents("php://input");
                     $data = \Zend_Json::decode($data);
                     $type = $data["type"];
                     $id = null;
                     $typeUpper = ucfirst($type);
                     $className = "\\Pimcore\\Model\\Webservice\\Data\\Document\\" . $typeUpper . "\\In";
                     if ($data["id"]) {
                         $doc = Document::getById($data["id"]);
                         if ($doc) {
                             $this->checkPermission($doc, "update");
                         }
                         $isUpdate = true;
                         $setter = "updateDocument" . $typeUpper;
                         if (!method_exists($this->service, $setter)) {
                             throw new \Exception("method does not exist " . $setter);
                         }
                         $wsData = self::fillWebserviceData($className, $data);
                         $success = $this->service->{$setter}($wsData);
                     } else {
                         $setter = "createDocument" . $typeUpper;
                         if (!method_exists($this->service, $setter)) {
                             throw new \Exception("method does not exist " . $setter);
                         }
                         $wsData = self::fillWebserviceData($className, $data);
                         $doc = new Document();
                         $doc->setId($wsData->parentId);
                         $this->checkPermission($doc, "create");
                         $id = $this->service->{$setter}($wsData);
                     }
                     if (!$isUpdate) {
                         $success = $id != null;
                     }
                     if ($success && !$isUpdate) {
                         $this->encoder->encode(array("success" => $success, "id" => $id));
                     } else {
                         $this->encoder->encode(array("success" => $success));
                     }
                     return;
//.........这里部分代码省略.........
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:101,代码来源:RestController.php

示例4: documentAction

 /** end point for document related data.
  * - get document by id
  *      GET http://[YOUR-DOMAIN]/webservice/rest/document/id/1281?apikey=[API-KEY]
  *      returns json-encoded document data.
  * - delete document by id
  *      DELETE http://[YOUR-DOMAIN]/webservice/rest/document/id/1281?apikey=[API-KEY]
  *      returns json encoded success value
  * - create document
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/document?apikey=[API-KEY]
  *      body: json-encoded document data in the same format as returned by get document by id
  *              but with missing id field or id set to 0
  *      returns json encoded document id
  * - update document
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/document?apikey=[API-KEY]
  *      body: same as for create document but with object id
  *      returns json encoded success value
  * @throws \Exception
  */
 public function documentAction()
 {
     $id = $this->getParam("id");
     $success = false;
     try {
         if ($this->isGet()) {
             /**
              * @api {get} /document Get document
              * @apiName getDocument
              * @apiGroup Document
              * @apiSampleRequest off
              * @apiParam {int} id The id of document you search
              * @apiParamExample {json} Request-Example:
              *     {
              *       "id": 4711
              *       "apikey": '2132sdf2321rwefdcvvce22'
              *     }
              * @apiParam {string} apikey your access token
              * @apiSuccess {boolean} success Returns true if finished successfully
              * @apiSuccessExample {json} Succes-Response:
              *                    HTTP/1.1 200 OK
              *                    {
              *                        "success":true
              *                    }
              * @apiError {boolean} success Returns false if failed
              * @apiErrorExample {json} Error-Response:
              *                  {"success":false,"msg":"exception 'Exception' with message 'Document with given ID (712131243) does not exist.'"}
              */
             $doc = Document::getById($id);
             if (!$doc) {
                 $this->encoder->encode(["success" => false, "msg" => "Document does not exist", "code" => self::ELEMENT_DOES_NOT_EXIST]);
                 return;
             }
             $this->checkPermission($doc, "get");
             if ($doc) {
                 $type = $doc->getType();
                 $getter = "getDocument" . ucfirst($type) . "ById";
                 if (method_exists($this->service, $getter)) {
                     $object = $this->service->{$getter}($id);
                 } else {
                     // check if the getter is implemented by a plugin
                     $class = "\\Pimcore\\Model\\Webservice\\Data\\Document\\" . ucfirst($type) . "\\Out";
                     if (Tool::classExists($class)) {
                         Document\Service::loadAllDocumentFields($doc);
                         $object = Webservice\Data\Mapper::map($doc, $class, "out");
                     } else {
                         throw new \Exception("unknown type");
                     }
                 }
             }
             if (!$object) {
                 throw new \Exception("could not find document");
             }
             @$this->encoder->encode(["success" => true, "data" => $object]);
             return;
         } elseif ($this->isDelete()) {
             /**
              * @api {delete} /document Delete document
              * @apiName deleteDocument
              * @apiGroup Document
              * @apiParam {int} id The id of document you delete
              * @apiSampleRequest off
              * @apiParamExample {json} Request-Example:
              *     {
              *       "id": 4711
              *       "apikey": '2132sdf2321rwefdcvvce22'
              *     }
              * @apiParam {string} apikey your access token
              * @apiSuccess {boolean} success Returns true if finished successfully
              * @apiSuccessExample {json} Succes-Response:
              *                    HTTP/1.1 200 OK
              *                    {
              *                        "success":true
              *                    }
              * @apiError {boolean} success Returns false if failed
              * @apiErrorExample {json} Error-Response:
              *                  {"success":false,"msg":"exception 'Exception' with message 'Document with given ID (712131243) does not exist.'"}
              */
             $doc = Document::getById($id);
             if ($doc) {
                 $this->checkPermission($doc, "delete");
             }
//.........这里部分代码省略.........
开发者ID:pimcore,项目名称:pimcore,代码行数:101,代码来源:RestController.php


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