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


PHP Model\Object类代码示例

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


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

示例1: subscribeAction

 public function subscribeAction()
 {
     $this->enableLayout();
     $newsletter = new Newsletter("person");
     // replace "crm" with the class name you have used for your class above (mailing list)
     $params = $this->getAllParams();
     $this->view->success = false;
     if ($newsletter->checkParams($params)) {
         try {
             $params["parentId"] = 1;
             // default folder (home) where we want to save our subscribers
             $newsletterFolder = Model\Object::getByPath("/crm/newsletter");
             if ($newsletterFolder) {
                 $params["parentId"] = $newsletterFolder->getId();
             }
             $user = $newsletter->subscribe($params);
             // user and email document
             // parameters available in the email: gender, firstname, lastname, email, token, object
             // ==> see mailing framework
             $newsletter->sendConfirmationMail($user, Model\Document::getByPath("/en/advanced-examples/newsletter/confirmation-email"), ["additional" => "parameters"]);
             // do some other stuff with the new user
             $user->setDateRegister(new \DateTime());
             $user->save();
             $this->view->success = true;
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:29,代码来源:NewsletterController.php

示例2: load

 /**
  * Loads a list of entries for the specicifies parameters, returns an array of Search\Backend\Data
  *
  * @return array
  */
 public function load()
 {
     $entries = array();
     $data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $entryData) {
         if ($entryData['maintype'] == 'document') {
             $element = Document::getById($entryData['id']);
         } else {
             if ($entryData['maintype'] == 'asset') {
                 $element = Asset::getById($entryData['id']);
             } else {
                 if ($entryData['maintype'] == 'object') {
                     $element = Object::getById($entryData['id']);
                 } else {
                     \Logger::err("unknown maintype ");
                 }
             }
         }
         if ($element) {
             $entry = new Search\Backend\Data();
             $entry->setId(new Search\Backend\Data\Id($element));
             $entry->setFullPath($entryData['fullpath']);
             $entry->setType($entryData['type']);
             $entry->setSubtype($entryData['subtype']);
             $entry->setUserOwner($entryData['userowner']);
             $entry->setUserModification($entryData['usermodification']);
             $entry->setCreationDate($entryData['creationdate']);
             $entry->setModificationDate($entryData['modificationdate']);
             $entry->setPublished($entryData['published'] === 0 ? false : true);
             $entries[] = $entry;
         }
     }
     $this->model->setEntries($entries);
     return $entries;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:40,代码来源:Dao.php

示例3: getAuth_PayerID

 /**
 * Set auth_PayerID - PayerID
 * @return string
 */
 public function getAuth_PayerID()
 {
     $data = $this->auth_PayerID;
     if (\Pimcore\Model\Object::doGetInheritedValues($this->getObject()) && $this->getDefinition()->getFieldDefinition("auth_PayerID")->isEmpty($data)) {
         return $this->getValueFromParent("auth_PayerID");
     }
     return $data;
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:12,代码来源:PaymentProviderPayPal.php

示例4: getSize

 /**
 * Set size - Size
 * @return string
 */
 public function getSize()
 {
     $data = $this->size;
     if (\Pimcore\Model\Object::doGetInheritedValues($this->getObject()) && $this->getDefinition()->getFieldDefinition("size")->isEmpty($data)) {
         return $this->getValueFromParent("size");
     }
     return $data;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:12,代码来源:CoreShopDimensionSize.php

示例5: getIdentificationShortId

 /**
 * Set identificationShortId - IdentificationShortId
 * @return string
 */
 public function getIdentificationShortId()
 {
     $data = $this->identificationShortId;
     if (\Pimcore\Model\Object::doGetInheritedValues($this->getObject()) && $this->getDefinition()->getFieldDefinition("identificationShortId")->isEmpty($data)) {
         return $this->getValueFromParent("identificationShortId");
     }
     return $data;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:12,代码来源:CoreShopPaymentPayunity.php

示例6: load

 /**
  * Loads a list of objects for the specicifies parameters, returns an array of Object\AbstractObject elements
  *
  * @return array
  */
 public function load()
 {
     $objects = array();
     $objectsData = $this->db->fetchAll("SELECT o_id,o_type FROM objects" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($objectsData as $objectData) {
         if ($object = Object::getById($objectData["o_id"])) {
             $objects[] = $object;
         }
     }
     $this->model->setObjects($objects);
     return $objects;
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:17,代码来源:Resource.php

示例7: load

 /**
  * Loads a list of objects for the specicifies parameters, returns an array of Object\AbstractObject elements
  *
  * @return array
  */
 public function load()
 {
     // load id's
     $list = $this->loadIdList();
     $objects = array();
     foreach ($list as $o_id) {
         if ($object = Object::getById($o_id)) {
             $objects[] = $object;
         }
     }
     $this->model->setObjects($objects);
     return $objects;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:18,代码来源:Dao.php

示例8: load

 /**
  * Loads a list of objects for the specified parameters, returns an array of Object\AbstractObject elements
  *
  * @return array 
  */
 public function load()
 {
     $objects = array();
     try {
         $field = $this->getTableName() . ".o_id";
         $sql = "SELECT " . $this->getSelectPart($field, $field) . " AS o_id,o_type FROM `" . $this->getTableName() . "`" . $this->getJoins() . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit();
         $objectsData = $this->db->fetchAll($sql, $this->model->getConditionVariables());
     } catch (\Exception $e) {
         return $this->exceptionHandler($e);
     }
     foreach ($objectsData as $objectData) {
         if ($object = Object::getById($objectData["o_id"])) {
             $objects[] = Object::getById($objectData["o_id"]);
         }
     }
     $this->model->setObjects($objects);
     return $objects;
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:23,代码来源:Resource.php

示例9: batchAction

 public function batchAction()
 {
     $success = true;
     try {
         $object = Object::getById($this->getParam("job"));
         if ($object) {
             $className = $object->getClassName();
             $class = Object\ClassDefinition::getByName($className);
             $value = $this->getParam("value");
             if ($this->getParam("valueType") == "object") {
                 $value = \Zend_Json::decode($value);
             }
             $name = $this->getParam("name");
             $parts = explode("~", $name);
             if (substr($name, 0, 1) == "~") {
                 $type = $parts[1];
                 $field = $parts[2];
                 $keyid = $parts[3];
                 $getter = "get" . ucfirst($field);
                 $setter = "set" . ucfirst($field);
                 $keyValuePairs = $object->{$getter}();
                 if (!$keyValuePairs) {
                     $keyValuePairs = new Object\Data\KeyValue();
                     $keyValuePairs->setObjectId($object->getId());
                     $keyValuePairs->setClass($object->getClass());
                 }
                 $keyValuePairs->setPropertyWithId($keyid, $value, true);
                 $object->{$setter}($keyValuePairs);
             } else {
                 if (count($parts) > 1) {
                     // check for bricks
                     $brickType = $parts[0];
                     $brickKey = $parts[1];
                     $brickField = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                     $fieldGetter = "get" . ucfirst($brickField);
                     $brickGetter = "get" . ucfirst($brickType);
                     $valueSetter = "set" . ucfirst($brickKey);
                     $brick = $object->{$fieldGetter}()->{$brickGetter}();
                     if (empty($brick)) {
                         $classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
                         $brickSetter = "set" . ucfirst($brickType);
                         $brick = new $classname($object);
                         $object->{$fieldGetter}()->{$brickSetter}($brick);
                     }
                     $brickClass = Object\Objectbrick\Definition::getByKey($brickType);
                     $field = $brickClass->getFieldDefinition($brickKey);
                     $brick->{$valueSetter}($field->getDataFromEditmode($value, $object));
                 } else {
                     // everything else
                     $field = $class->getFieldDefinition($name);
                     if ($field) {
                         $object->setValue($name, $field->getDataFromEditmode($value, $object));
                     } else {
                         // check if it is a localized field
                         if ($this->getParam("language")) {
                             $localizedField = $class->getFieldDefinition("localizedfields");
                             if ($localizedField) {
                                 $field = $localizedField->getFieldDefinition($name);
                                 if ($field) {
                                     $object->{"set" . $name}($value, $this->getParam("language"));
                                 }
                             }
                         }
                         // seems to be a system field, this is actually only possible for the "published" field yet
                         if ($name == "published") {
                             if ($value == "false" || empty($value)) {
                                 $object->setPublished(false);
                             } else {
                                 $object->setPublished(true);
                             }
                         }
                     }
                 }
             }
             try {
                 // don't check for mandatory fields here
                 $object->setOmitMandatoryCheck(true);
                 $object->setUserModification($this->getUser()->getId());
                 $object->save();
                 $success = true;
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         } else {
             \Logger::debug("ObjectController::batchAction => There is no object left to update.");
             $this->_helper->json(array("success" => false, "message" => "ObjectController::batchAction => There is no object left to update."));
         }
     } catch (\Exception $e) {
         \Logger::err($e);
         $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
     }
     $this->_helper->json(array("success" => $success));
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:93,代码来源:ObjectHelperController.php

示例10: processRemoteOwnerRelations

 /**
  * @param  Object\Concrete $object
  * @param  array $toDelete
  * @param  array $toAdd
  * @param  string $ownerFieldName
  * @return void
  */
 protected function processRemoteOwnerRelations($object, $toDelete, $toAdd, $ownerFieldName)
 {
     $getter = "get" . ucfirst($ownerFieldName);
     $setter = "set" . ucfirst($ownerFieldName);
     foreach ($toDelete as $id) {
         $owner = Object::getById($id);
         //TODO: lock ?!
         if (method_exists($owner, $getter)) {
             $currentData = $owner->{$getter}();
             if (is_array($currentData)) {
                 for ($i = 0; $i < count($currentData); $i++) {
                     if ($currentData[$i]->getId() == $object->getId()) {
                         unset($currentData[$i]);
                         $owner->{$setter}($currentData);
                         $owner->setUserModification($this->getUser()->getId());
                         $owner->save();
                         \Logger::debug("Saved object id [ " . $owner->getId() . " ] by remote modification through [" . $object->getId() . "], Action: deleted [ " . $object->getId() . " ] from [ {$ownerFieldName}]");
                         break;
                     }
                 }
             }
         }
     }
     foreach ($toAdd as $id) {
         $owner = Object::getById($id);
         //TODO: lock ?!
         if (method_exists($owner, $getter)) {
             $currentData = $owner->{$getter}();
             $currentData[] = $object;
             $owner->{$setter}($currentData);
             $owner->setUserModification($this->getUser()->getId());
             $owner->save();
             \Logger::debug("Saved object id [ " . $owner->getId() . " ] by remote modification through [" . $object->getId() . "], Action: added [ " . $object->getId() . " ] to [ {$ownerFieldName} ]");
         }
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:43,代码来源:ObjectController.php

示例11: buildTree

 /**
  * @param $currentParentId
  * @param string $fields
  * @return array
  */
 protected function buildTree($currentParentId, $fields = "", $parentIdGroups = null)
 {
     if (!$parentIdGroups) {
         $object = Object::getById($currentParentId);
         $result = $this->db->fetchAll("SELECT b.o_id AS id {$fields}, b.o_type AS type, b.o_parentId AS parentId, CONCAT(o_path,o_key) as fullpath FROM objects b LEFT JOIN " . $this->storetable . " a ON b.o_id = a." . $this->idField . " WHERE o_path LIKE ? GROUP BY b.o_id ORDER BY LENGTH(o_path) ASC", $object->getFullPath() . "/%");
         $objects = array();
         // group the results together based on the parent id's
         $parentIdGroups = [];
         foreach ($result as $r) {
             if (!isset($parentIdGroups[$r["parentId"]])) {
                 $parentIdGroups[$r["parentId"]] = [];
             }
             $parentIdGroups[$r["parentId"]][] = $r;
         }
     }
     if (isset($parentIdGroups[$currentParentId])) {
         foreach ($parentIdGroups[$currentParentId] as $r) {
             $o = new \stdClass();
             $o->id = $r['id'];
             $o->values = $r;
             $o->type = $r["type"];
             $o->childs = $this->buildTree($r['id'], $fields, $parentIdGroups);
             $objects[] = $o;
         }
     }
     return $objects;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:32,代码来源:InheritanceHelper.php

示例12: objectAction

 /** end point for object related data.
  * - get object by id
  *      GET http://[YOUR-DOMAIN]/webservice/rest/object/id/1281?apikey=[API-KEY]
  *      returns json-encoded object data.
  * - delete object by id
  *      DELETE http://[YOUR-DOMAIN]/webservice/rest/object/id/1281?apikey=[API-KEY]
  *      returns json encoded success value
  * - create object
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/object?apikey=[API-KEY]
  *      body: json-encoded object data in the same format as returned by get object by id
  *              but with missing id field or id set to 0
  *      returns json encoded object id
  * - update object
  *      PUT or POST http://[YOUR-DOMAIN]/webservice/rest/object?apikey=[API-KEY]
  *      body: same as for create object but with object id
  *      returns json encoded success value
  * @throws \Exception
  */
 public function objectAction()
 {
     $id = $this->getParam("id");
     $success = false;
     try {
         if ($this->isGet()) {
             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";
                         }
//.........这里部分代码省略.........
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:101,代码来源:RestController.php

示例13: restore

 /**
  *
  */
 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object\AbstractObject) {
                 $indentElement = Object::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:31,代码来源:Item.php

示例14: getVariantsAction

 public function getVariantsAction()
 {
     // get list of variants
     if ($this->getParam("language")) {
         $this->setLanguage($this->getParam("language"), true);
     }
     if ($this->getParam("xaction") == "update") {
         $data = \Zend_Json::decode($this->getParam("data"));
         // save
         $object = Object::getById($data["id"]);
         if ($object->isAllowed("publish")) {
             $objectData = [];
             foreach ($data as $key => $value) {
                 $parts = explode("~", $key);
                 if (substr($key, 0, 1) == "~") {
                     $type = $parts[1];
                     $field = $parts[2];
                     $keyid = $parts[3];
                     $getter = "get" . ucfirst($field);
                     $setter = "set" . ucfirst($field);
                     $keyValuePairs = $object->{$getter}();
                     if (!$keyValuePairs) {
                         $keyValuePairs = new Object\Data\KeyValue();
                         $keyValuePairs->setObjectId($object->getId());
                         $keyValuePairs->setClass($object->getClass());
                     }
                     $keyValuePairs->setPropertyWithId($keyid, $value, true);
                     $object->{$setter}($keyValuePairs);
                 } elseif (count($parts) > 1) {
                     $brickType = $parts[0];
                     $brickKey = $parts[1];
                     $brickField = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                     $fieldGetter = "get" . ucfirst($brickField);
                     $brickGetter = "get" . ucfirst($brickType);
                     $valueSetter = "set" . ucfirst($brickKey);
                     $brick = $object->{$fieldGetter}()->{$brickGetter}();
                     if (empty($brick)) {
                         $classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
                         $brickSetter = "set" . ucfirst($brickType);
                         $brick = new $classname($object);
                         $object->{$fieldGetter}()->{$brickSetter}($brick);
                     }
                     $brick->{$valueSetter}($value);
                 } else {
                     $objectData[$key] = $value;
                 }
             }
             $object->setValues($objectData);
             try {
                 $object->save();
                 $this->_helper->json(["data" => Object\Service::gridObjectData($object, $this->getParam("fields")), "success" => true]);
             } catch (\Exception $e) {
                 $this->_helper->json(["success" => false, "message" => $e->getMessage()]);
             }
         } else {
             throw new \Exception("Permission denied");
         }
     } else {
         $parentObject = Object\Concrete::getById($this->getParam("objectId"));
         if (empty($parentObject)) {
             throw new \Exception("No Object found with id " . $this->getParam("objectId"));
         }
         if ($parentObject->isAllowed("view")) {
             $class = $parentObject->getClass();
             $className = $parentObject->getClass()->getName();
             $start = 0;
             $limit = 15;
             $orderKey = "o_id";
             $order = "ASC";
             $fields = [];
             $bricks = [];
             if ($this->getParam("fields")) {
                 $fields = $this->getParam("fields");
                 foreach ($fields as $f) {
                     $parts = explode("~", $f);
                     if (count($parts) > 1) {
                         $bricks[$parts[0]] = $parts[0];
                     }
                 }
             }
             if ($this->getParam("limit")) {
                 $limit = $this->getParam("limit");
             }
             if ($this->getParam("start")) {
                 $start = $this->getParam("start");
             }
             $orderKey = "o_id";
             $order = "ASC";
             $colMappings = ["filename" => "o_key", "fullpath" => ["o_path", "o_key"], "id" => "o_id", "published" => "o_published", "modificationDate" => "o_modificationDate", "creationDate" => "o_creationDate"];
             $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
             if ($sortingSettings['orderKey'] && $sortingSettings['order']) {
                 $orderKey = $sortingSettings['orderKey'];
                 if (array_key_exists($orderKey, $colMappings)) {
                     $orderKey = $colMappings[$orderKey];
                 }
                 $order = $sortingSettings['order'];
             }
             if ($this->getParam("dir")) {
                 $order = $this->getParam("dir");
             }
//.........这里部分代码省略.........
开发者ID:solverat,项目名称:pimcore,代码行数:101,代码来源:VariantsController.php

示例15: execute

 /**
  *
  */
 public static function execute()
 {
     $list = new Listing();
     $list->setCondition("active = 1 AND date < ?", time());
     $tasks = $list->load();
     foreach ($tasks as $task) {
         try {
             if ($task->getCtype() == "document") {
                 $document = Document::getById($task->getCid());
                 if ($document instanceof Document) {
                     if ($task->getAction() == "publish-version" && $task->getVersion()) {
                         try {
                             $version = Version::getById($task->getVersion());
                             $document = $version->getData();
                             if ($document instanceof Document) {
                                 $document->setPublished(true);
                                 $document->save();
                             } else {
                                 \Logger::err("Schedule\\Task\\Executor: Could not restore document from version data.");
                             }
                         } catch (\Exception $e) {
                             \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                         }
                     } else {
                         if ($task->getAction() == "publish") {
                             $document->setPublished(true);
                             $document->save();
                         } else {
                             if ($task->getAction() == "unpublish") {
                                 $document->setPublished(false);
                                 $document->save();
                             } else {
                                 if ($task->getAction() == "delete") {
                                     $document->delete();
                                 }
                             }
                         }
                     }
                 }
             } else {
                 if ($task->getCtype() == "asset") {
                     $asset = Asset::getById($task->getCid());
                     if ($asset instanceof Asset) {
                         if ($task->getAction() == "publish-version" && $task->getVersion()) {
                             try {
                                 $version = Version::getById($task->getVersion());
                                 $asset = $version->getData();
                                 if ($asset instanceof Asset) {
                                     $asset->save();
                                 } else {
                                     \Logger::err("Schedule\\Task\\Executor: Could not restore asset from version data.");
                                 }
                             } catch (\Exception $e) {
                                 \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                             }
                         } else {
                             if ($task->getAction() == "delete") {
                                 $asset->delete();
                             }
                         }
                     }
                 } else {
                     if ($task->getCtype() == "object") {
                         $object = Object::getById($task->getCid());
                         if ($object instanceof Object) {
                             if ($task->getAction() == "publish-version" && $task->getVersion()) {
                                 try {
                                     $version = Version::getById($task->getVersion());
                                     $object = $version->getData();
                                     if ($object instanceof Object\AbstractObject) {
                                         $object->setPublished(true);
                                         $object->save();
                                     } else {
                                         \Logger::err("Schedule\\Task\\Executor: Could not restore object from version data.");
                                     }
                                 } catch (\Exception $e) {
                                     \Logger::err("Schedule\\Task\\Executor: Version [ " . $task->getVersion() . " ] does not exist.");
                                 }
                             } else {
                                 if ($task->getAction() == "publish") {
                                     $object->setPublished(true);
                                     $object->save();
                                 } else {
                                     if ($task->getAction() == "unpublish") {
                                         $object->setPublished(false);
                                         $object->save();
                                     } else {
                                         if ($task->getAction() == "delete") {
                                             $object->delete();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:ptaferner,项目名称:pimcore,代码行数:101,代码来源:Executor.php


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