本文整理汇总了PHP中Pimcore\Model\Object::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::setId方法的具体用法?PHP Object::setId怎么用?PHP Object::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Object
的用法示例。
在下文中一共展示了Object::setId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: objectAction
//.........这里部分代码省略.........
if ($id) {
$profile = $this->getParam("profiling");
if ($profile) {
$startTs = microtime(true);
}
$object = Object::getById($id);
if (!$object) {
$this->encoder->encode(array("success" => false, "msg" => "Object does not exist", "code" => self::ELEMENT_DOES_NOT_EXIST));
return;
}
if ($profile) {
$timeConsumedGet = round(microtime(true) - $startTs, 3) * 1000;
$startTs = microtime(true);
}
$this->checkPermission($object, "get");
if ($profile) {
$timeConsumedPerm = round(microtime(true) - $startTs, 3) * 1000;
$startTs = microtime(true);
}
if ($object instanceof Object\Folder) {
$object = $this->service->getObjectFolderById($id);
} else {
$object = $this->service->getObjectConcreteById($id);
}
if ($profile) {
$timeConsumedGetWebservice = round(microtime(true) - $startTs, 3) * 1000;
}
if ($profile) {
$profiling = array();
$profiling["get"] = $timeConsumedGet;
$profiling["perm"] = $timeConsumedPerm;
$profiling["ws"] = $timeConsumedGetWebservice;
$profiling["init"] = $this->timeConsumedInit;
$result = array("success" => true, "profiling" => $profiling, "data" => $object);
} else {
$result = array("success" => true, "data" => $object);
}
$this->encoder->encode($result);
return;
}
} else {
if ($this->isDelete()) {
$object = Object::getById($id);
if ($object) {
$this->checkPermission($object, "delete");
}
$success = $this->service->deleteObject($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;
if ($data["id"]) {
$obj = Object::getById($data["id"]);
if ($obj) {
$this->checkPermission($obj, "update");
}
$isUpdate = true;
if ($type == "folder") {
$wsData = self::fillWebserviceData("\\Pimcore\\Model\\Webservice\\Data\\Object\\Folder\\In", $data);
$success = $this->service->updateObjectFolder($wsData);
} else {
$wsData = self::fillWebserviceData("\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In", $data);
$success = $this->service->updateObjectConcrete($wsData);
}
} else {
if ($type == "folder") {
$class = "\\Pimcore\\Model\\Webservice\\Data\\Object\\Folder\\In";
$method = "createObjectFolder";
} else {
$class = "\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In";
$method = "createObjectConcrete";
}
$wsData = self::fillWebserviceData($class, $data);
$obj = new Object();
$obj->setId($wsData->parentId);
$this->checkPermission($obj, "create");
$id = $this->service->{$method}($wsData);
}
if (!$isUpdate) {
$success = $id != null;
}
$result = array("success" => $success);
if ($success && !$isUpdate) {
$result["id"] = $id;
}
$this->encoder->encode($result);
return;
}
}
}
} catch (\Exception $e) {
\Logger::error($e);
$this->encoder->encode(array("success" => false, "msg" => (string) $e));
}
throw new \Exception("not implemented");
}
示例2: objectAction
//.........这里部分代码省略.........
} else {
/**
* @api {put} /object Create a new object
* @apiName Create a new object
* @apiGroup Object
* @apiSampleRequest off
* @apiDescription
* Request body: JSON-encoded object data in the same format as returned by get object by id for the data segment but with missing id field or id set to 0
*
* @apiParam {json} data a new object data
* @apiParam {string} apikey your access token
* @apiParamExample {json} Request-Example:
* {
* "apikey": "21314njdsfn1342134",
* "data": {
* "id": 61,
* "parentId": 48,
* "key": "test-product-key",
* "className": "product",
* "type": "object",
* "elements": [
* {
* "type": "input",
* "value": "some identyfier",
* "name": "identyfier",
* "language": null
* },
* {
* "type": "localizedfields",
* "value": [
* {
* "type": "input",
* "value": "Test",
* "name": "name1",
* "language": "en"
* },
* {
* "type": "input",
* "value": "1",
* "name": "name2",
* "language": "en"
* },
* {
* "type": "input",
* "value": null,
* "name": "name1",
* "language": "de"
* },
* {
* "type": "input",
* "value": "aaa",
* "name": "name2",
* "language": "de"
* }
* ],
* "name": "localizedfields",
* "language": null
* }
* ]
* }
* }
* @apiSuccess {json} success parameter of the returned data = true
* @apiError {json} success parameter of the returned data = false
* @apiErrorExample {json} Error-Response:
* {"success":false, "msg":"exception 'Exception' with message '....'"}
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "success": true
* }
*/
if ($type == "folder") {
$class = "\\Pimcore\\Model\\Webservice\\Data\\Object\\Folder\\In";
$method = "createObjectFolder";
} else {
$class = "\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In";
$method = "createObjectConcrete";
}
$wsData = self::fillWebserviceData($class, $data);
$obj = new Object();
$obj->setId($wsData->parentId);
$this->checkPermission($obj, "create");
$id = $this->service->{$method}($wsData);
}
if (!$isUpdate) {
$success = $id != null;
}
$result = ["success" => $success];
if ($success && !$isUpdate) {
$result["id"] = $id;
}
$this->encoder->encode($result);
return;
}
} catch (\Exception $e) {
Logger::error($e);
$this->encoder->encode(["success" => false, "msg" => (string) $e]);
}
throw new \Exception("not implemented");
}