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


PHP Tool\Serialize类代码示例

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


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

示例1: save

 /**
  *
  */
 public function save()
 {
     $data = $this->model->getDataForResource();
     if (is_array($data) or is_object($data)) {
         $data = \Pimcore\Tool\Serialize::serialize($data);
     }
     $element = array("data" => $data, "documentId" => $this->model->getDocumentId(), "name" => $this->model->getName(), "type" => $this->model->getType());
     $this->db->insertOrUpdate("documents_elements", $element);
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:12,代码来源:Dao.php

示例2: direct

 /**
  * @param mixed $data
  * @param bool $sendNow
  * @param bool $keepLayouts
  * @param bool $encodeData
  * @return string|void
  */
 public function direct($data, $sendNow = true, $keepLayouts = false, $encodeData = true)
 {
     if ($encodeData) {
         $data = \Pimcore\Tool\Serialize::removeReferenceLoops($data);
     }
     // hack for FCGI because ZF doesn't care of duplicate headers
     $this->getResponse()->clearHeader("Content-Type");
     $this->suppressExit = !$sendNow;
     $d = $this->sendJson($data, $keepLayouts, $encodeData);
     return $d;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:18,代码来源:Json.php

示例3: upperCastDocument

 /**
  * @static
  * @param Document $doc
  * @return Document
  */
 public static function upperCastDocument(Document $doc)
 {
     $to_class = "Pimcore\\Model\\Document\\Hardlink\\Wrapper\\" . ucfirst($doc->getType());
     $old_serialized_prefix = "O:" . strlen(get_class($doc));
     $old_serialized_prefix .= ":\"" . get_class($doc) . "\":";
     // unset eventually existing children, because of performance reasons when serializing the document
     $doc->setChilds(null);
     $old_serialized_object = Serialize::serialize($doc);
     $new_serialized_object = 'O:' . strlen($to_class) . ':"' . $to_class . '":';
     $new_serialized_object .= substr($old_serialized_object, strlen($old_serialized_prefix));
     $document = Serialize::unserialize($new_serialized_object);
     return $document;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:18,代码来源:Service.php

示例4: encode

 public function encode($data, $returnData = false)
 {
     $data = \Pimcore\Tool\Serialize::removeReferenceLoops($data);
     $data = \Zend_Json::encode($data, null, array());
     if ($returnData) {
         return $data;
     } else {
         $response = \Zend_Controller_Front::getInstance()->getResponse();
         $response->setHeader('Content-Type', 'application/json', true);
         $response->setBody($data);
         $response->sendResponse();
         exit;
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:14,代码来源:JsonEncoder.php

示例5: update

 /**
  * Save changes to database, it's an good idea to use save() instead
  *
  * @return void
  */
 public function update()
 {
     $site = get_object_vars($this->model);
     foreach ($site as $key => $value) {
         if (in_array($key, $this->getValidTableColumns("schedule_tasks"))) {
             if (is_array($value) || is_object($value)) {
                 $value = \Pimcore\Tool\Serialize::serialize($value);
             } elseif (is_bool($value)) {
                 $value = (int) $value;
             }
             $data[$key] = $value;
         }
     }
     $this->db->update("schedule_tasks", $data, $this->db->quoteInto("id = ?", $this->model->getId()));
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:20,代码来源:Dao.php

示例6: delete

 /**
  * @throws DAV\Exception\Forbidden
  * @throws \Exception
  */
 function delete()
 {
     if ($this->asset->isAllowed("delete")) {
         Asset\Service::loadAllFields($this->asset);
         $this->asset->delete();
         // add the asset to the delete history, this is used so come over problems with programs like photoshop (delete, create instead of replace => move)
         // for details see Asset\WebDAV\Tree::move()
         $log = Asset\WebDAV\Service::getDeleteLog();
         $this->asset->_fulldump = true;
         $log[$this->asset->getFullpath()] = array("id" => $this->asset->getId(), "timestamp" => time(), "data" => \Pimcore\Tool\Serialize::serialize($this->asset));
         unset($this->asset->_fulldump);
         Asset\WebDAV\Service::saveDeleteLog($log);
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:20,代码来源:File.php

示例7: save

 /**
  * Save object to database
  *
  * @return void
  */
 public function save()
 {
     $data = $this->model->getData();
     if ($this->model->getType() == "object" || $this->model->getType() == "asset" || $this->model->getType() == "document") {
         if ($data instanceof Model\Element\ElementInterface) {
             $data = $data->getId();
         } else {
             $data = null;
         }
     }
     if (is_array($data) || is_object($data)) {
         $data = \Pimcore\Tool\Serialize::serialize($data);
     }
     $saveData = array("cid" => $this->model->getCid(), "ctype" => $this->model->getCtype(), "cpath" => $this->model->getCpath(), "name" => $this->model->getName(), "type" => $this->model->getType(), "inheritable" => (int) $this->model->getInheritable(), "data" => $data);
     $this->db->insertOrUpdate("properties", $saveData);
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:21,代码来源:Resource.php

示例8: load

 /**
  * @return array
  */
 public function load()
 {
     $fields = array();
     $objectBricksFolder = PIMCORE_CLASS_DIRECTORY . "/objectbricks";
     if (is_dir($objectBricksFolder)) {
         $files = scandir($objectBricksFolder);
         foreach ($files as $file) {
             $file = $objectBricksFolder . "/" . $file;
             if (is_file($file)) {
                 $fieldData = file_get_contents($file);
                 $fields[] = \Pimcore\Tool\Serialize::unserialize($fieldData);
             }
         }
     }
     return $fields;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:19,代码来源:Listing.php

示例9: load

 /**
  * @return array
  */
 public function load()
 {
     $fields = [];
     $fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections";
     if (is_dir($fieldCollectionFolder)) {
         $files = scandir($fieldCollectionFolder);
         foreach ($files as $file) {
             $file = $fieldCollectionFolder . "/" . $file;
             if (is_file($file)) {
                 $fieldData = file_get_contents($file);
                 $fields[] = \Pimcore\Tool\Serialize::unserialize($fieldData);
             }
         }
     }
     return $fields;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:19,代码来源:Listing.php

示例10: getById

 /**
  * Get the data for the object by the given id, or by the id which is set in the object
  *
  * @param integer $id
  * @throws \Exception
  */
 public function getById($id = null)
 {
     try {
         if ($id != null) {
             $this->model->setId($id);
         }
         $data = $this->db->fetchRow("SELECT documents.*, documents_page.*, tree_locks.locked FROM documents\n                LEFT JOIN documents_page ON documents.id = documents_page.id\n                LEFT JOIN tree_locks ON documents.id = tree_locks.id AND tree_locks.type = 'document'\n                    WHERE documents.id = ?", $this->model->getId());
         if ($data["id"] > 0) {
             $data["metaData"] = Serialize::unserialize($data["metaData"]);
             $this->assignVariablesToModel($data);
         } else {
             throw new \Exception("Page with the ID " . $this->model->getId() . " doesn't exists");
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:23,代码来源:Resource.php

示例11: move

 /**
  * Moves a file/directory
  *
  * @param string $sourcePath
  * @param string $destinationPath
  * @return void
  */
 public function move($sourcePath, $destinationPath)
 {
     $nameParts = explode("/", $sourcePath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             $asset = null;
             if ($asset = Asset::getByPath("/" . $destinationPath)) {
                 // If we got here, this means the destination exists, and needs to be overwritten
                 $sourceAsset = Asset::getByPath("/" . $sourcePath);
                 $asset->setData($sourceAsset->getData());
                 $sourceAsset->delete();
             }
             // see: Asset\WebDAV\File::delete() why this is necessary
             $log = Asset\WebDAV\Service::getDeleteLog();
             if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
                 $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
                 if ($asset) {
                     $sourceAsset = Asset::getByPath("/" . $sourcePath);
                     $asset->setData($sourceAsset->getData());
                     $sourceAsset->delete();
                 }
             }
             if (!$asset) {
                 $asset = Asset::getByPath("/" . $sourcePath);
             }
             $asset->setFilename(basename($destinationPath));
         } else {
             $asset = Asset::getByPath("/" . $sourcePath);
             $parent = Asset::getByPath("/" . dirname($destinationPath));
             $asset->setPath($parent->getFullPath() . "/");
             $asset->setParentId($parent->getId());
         }
         $user = \Pimcore\Tool\Admin::getCurrentUser();
         $asset->setUserModification($user->getId());
         $asset->save();
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:51,代码来源:Tree.php

示例12: update

 /**
  * @throws \Exception
  */
 public function update()
 {
     try {
         $type = get_object_vars($this->model);
         foreach ($type as $key => $value) {
             if (in_array($key, $this->getValidTableColumns("targeting_personas"))) {
                 if (is_array($value) || is_object($value)) {
                     $value = Serialize::serialize($value);
                 }
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
                 $data[$key] = $value;
             }
         }
         $this->db->update("targeting_personas", $data, $this->db->quoteInto("id = ?", $this->model->getId()));
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:23,代码来源:Resource.php

示例13: update

 /**
  * @throws \Exception
  */
 public function update()
 {
     try {
         $type = get_object_vars($this->model);
         foreach ($type as $key => $value) {
             if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_RELATIONS))) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
                 if (is_array($value) || is_object($value)) {
                     $value = \Pimcore\Tool\Serialize::serialize($value);
                 }
                 $data[$key] = $value;
             }
         }
         $this->db->insertOrUpdate(self::TABLE_NAME_RELATIONS, $data);
         return $this->model;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:24,代码来源:Dao.php

示例14: update

 /**
  * @throws \Exception
  */
 public function update()
 {
     try {
         $ts = time();
         $this->model->setModificationDate($ts);
         $type = get_object_vars($this->model);
         foreach ($type as $key => $value) {
             if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_KEYS))) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
                 if (is_array($value) || is_object($value)) {
                     if ($this->model->getType() == 'select') {
                         $value = \Zend_Json::encode($value);
                     } else {
                         $value = \Pimcore\Tool\Serialize::serialize($value);
                     }
                 }
                 $data[$key] = $value;
             }
         }
         $this->db->update(self::TABLE_NAME_KEYS, $data, $this->db->quoteInto("id = ?", $this->model->getId()));
         return $this->model;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:30,代码来源:Dao.php

示例15: saveFolderAction

 public function saveFolderAction()
 {
     $object = Object::getById($this->getParam("id"));
     $classId = $this->getParam("class_id");
     // general settings
     $general = \Zend_Json::decode($this->getParam("general"));
     $object->setValues($general);
     $object->setUserModification($this->getUser()->getId());
     $object = $this->assignPropertiesFromEditmode($object);
     if ($object->isAllowed("publish")) {
         try {
             // grid config
             $gridConfig = \Zend_Json::decode($this->getParam("gridconfig"));
             if ($classId) {
                 $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "_" . $classId . "-user_" . $this->getUser()->getId() . ".psf";
             } else {
                 $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf";
             }
             $configDir = dirname($configFile);
             if (!is_dir($configDir)) {
                 File::mkdir($configDir);
             }
             File::put($configFile, Tool\Serialize::serialize($gridConfig));
             $object->save();
             $this->_helper->json(array("success" => true));
         } catch (\Exception $e) {
             $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
         }
     }
     $this->_helper->json(array("success" => false, "message" => "missing_permission"));
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:31,代码来源:ObjectController.php


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