本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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()));
}
示例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();
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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"));
}