本文整理汇总了PHP中Pimcore\Tool\Serialize::unserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Serialize::unserialize方法的具体用法?PHP Serialize::unserialize怎么用?PHP Serialize::unserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool\Serialize
的用法示例。
在下文中一共展示了Serialize::unserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: restore
/**
*
*/
public function restore($user = null)
{
$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");
}
} elseif ($element instanceof Asset) {
$indentElement = Asset::getByPath($element->getFullpath());
if ($indentElement) {
$element->setFilename($element->getFilename() . "_restore");
}
} elseif ($element instanceof Object\AbstractObject) {
$indentElement = Object::getByPath($element->getFullpath());
if ($indentElement) {
$element->setKey($element->getKey() . "_restore");
}
}
if (\Pimcore\Tool\Admin::getCurrentUser()) {
$parent = $element->getParent();
if (!$parent->isAllowed("publish")) {
throw new \Exception("Not sufficient permissions");
}
}
$this->restoreChilds($element);
$this->delete();
}
示例3: getLayoutData
/**
* Save object to database
*
* @return mixed
*/
protected function getLayoutData()
{
$file = PIMCORE_CUSTOMLAYOUT_DIRECTORY . "/custom_definition_" . $this->model->getId() . ".psf";
if (is_file($file)) {
return Serialize::unserialize(file_get_contents($file));
}
return;
}
示例4: 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;
}
示例5: getById
/**
* @param null $id
* @throws \Exception
*/
public function getById($id = null)
{
if ($id != null) {
$this->model->setId($id);
}
$data = $this->db->fetchRow("SELECT * FROM targeting_rules WHERE id = ?", $this->model->getId());
if ($data["id"]) {
$data["conditions"] = Serialize::unserialize($data["conditions"]);
$data["actions"] = isset($data["actions"]) ? Serialize::unserialize($data["actions"]) : [];
$this->assignVariablesToModel($data);
} else {
throw new \Exception("target with id " . $this->model->getId() . " doesn't exist");
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
}
示例9: 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);
}
}
示例10: loadFile
/**
* @return array|mixed
*/
protected function loadFile()
{
if (!is_dir($this->getConfigDir())) {
File::mkdir($this->getConfigDir());
}
if (empty($this->dashboards)) {
if (is_file($this->getConfigFile())) {
$dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
if (!empty($dashboards)) {
$this->dashboards = $dashboards;
}
}
if (empty($this->dashboards)) {
// if no configuration exists, return the base config
$this->dashboards = array("welcome" => array("positions" => array(array(array("id" => 1, "type" => "pimcore.layout.portlets.modificationStatistic", "config" => null), array("id" => 2, "type" => "pimcore.layout.portlets.modifiedAssets", "config" => null)), array(array("id" => 3, "type" => "pimcore.layout.portlets.modifiedObjects", "config" => null), array("id" => 4, "type" => "pimcore.layout.portlets.modifiedDocuments", "config" => null)))));
}
}
return $this->dashboards;
}
示例11: loadFile
/**
* @return array|mixed
*/
protected function loadFile()
{
if (!is_dir($this->getConfigDir())) {
File::mkdir($this->getConfigDir());
}
if (empty($this->dashboards)) {
if (is_file($this->getConfigFile())) {
$dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
if (!empty($dashboards)) {
$this->dashboards = $dashboards;
}
}
if (empty($this->dashboards)) {
$perspectiveCfg = Config::getRuntimePerspective();
$dasboardCfg = $perspectiveCfg["dashboards"] ? $perspectiveCfg["dashboards"] : [];
$this->dashboards = $dasboardCfg["predefined"] ? $dasboardCfg["predefined"] : [];
}
}
return $this->dashboards;
}
示例12: setDataFromResource
/**
* @see Document\Tag\TagInterface::setDataFromResource
* @param mixed $data
* @return void
*/
public function setDataFromResource($data)
{
$data = \Pimcore\Tool\Serialize::unserialize($data);
$this->id = $data["id"];
$this->type = $data["type"];
$this->subtype = $data["subtype"];
$this->setElement();
return $this;
}
示例13: gridGetColumnConfigAction
public function gridGetColumnConfigAction()
{
if ($this->getParam("id")) {
$class = Object\ClassDefinition::getById($this->getParam("id"));
} else {
if ($this->getParam("name")) {
$class = Object\ClassDefinition::getByName($this->getParam("name"));
}
}
$gridType = "search";
if ($this->getParam("gridtype")) {
$gridType = $this->getParam("gridtype");
}
$objectId = $this->getParam("objectId");
if ($objectId) {
$fields = Object\Service::getCustomGridFieldDefinitions($class->getId(), $objectId);
}
if (!$fields) {
$fields = $class->getFieldDefinitions();
}
$types = array();
if ($this->getParam("types")) {
$types = explode(",", $this->getParam("types"));
}
// grid config
$gridConfig = array();
if ($objectId) {
$configFiles["configFileClassUser"] = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $this->getParam("objectId") . "_" . $class->getId() . "-user_" . $this->getUser()->getId() . ".psf";
$configFiles["configFileUser"] = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $this->getParam("objectId") . "-user_" . $this->getUser()->getId() . ".psf";
foreach ($configFiles as $configFile) {
if (is_file($configFile)) {
$gridConfig = Tool\Serialize::unserialize(file_get_contents($configFile));
if (is_array($gridConfig) && array_key_exists("classId", $gridConfig)) {
if ($gridConfig["classId"] == $class->getId()) {
break;
} else {
$gridConfig = array();
}
} else {
break;
}
}
}
}
$localizedFields = array();
$objectbrickFields = array();
foreach ($fields as $key => $field) {
if ($field instanceof Object\ClassDefinition\Data\Localizedfields) {
$localizedFields[] = $field;
} else {
if ($field instanceof Object\ClassDefinition\Data\Objectbricks) {
$objectbrickFields[] = $field;
}
}
}
$availableFields = array();
$systemColumns = array("id", "fullpath", "published", "creationDate", "modificationDate", "filename", "classname");
if (empty($gridConfig)) {
$count = 0;
if (!$this->getParam("no_system_columns")) {
$vis = $class->getPropertyVisibility();
foreach ($systemColumns as $sc) {
$key = $sc;
if ($key == "fullpath") {
$key = "path";
}
if (empty($types) && ($vis[$gridType][$key] || $gridType == "all")) {
$availableFields[] = array("key" => $sc, "type" => "system", "label" => $sc, "position" => $count);
$count++;
}
}
}
$includeBricks = !$this->getParam("no_brick_columns");
foreach ($fields as $key => $field) {
if ($field instanceof Object\ClassDefinition\Data\Localizedfields) {
foreach ($field->getFieldDefinitions() as $fd) {
if (empty($types) || in_array($fd->getFieldType(), $types)) {
$fieldConfig = $this->getFieldGridConfig($fd, $gridType, $count);
if (!empty($fieldConfig)) {
$availableFields[] = $fieldConfig;
$count++;
}
}
}
} else {
if ($field instanceof Object\ClassDefinition\Data\Objectbricks && $includeBricks) {
if (in_array($field->getFieldType(), $types)) {
$fieldConfig = $this->getFieldGridConfig($field, $gridType, $count);
if (!empty($fieldConfig)) {
$availableFields[] = $fieldConfig;
$count++;
}
} else {
$allowedTypes = $field->getAllowedTypes();
if (!empty($allowedTypes)) {
foreach ($allowedTypes as $t) {
$brickClass = Object\Objectbrick\Definition::getByKey($t);
$brickFields = $brickClass->getFieldDefinitions();
if (!empty($brickFields)) {
foreach ($brickFields as $bf) {
//.........这里部分代码省略.........
示例14: setDomains
/**
* @param mixed $domains
* @return void
*/
public function setDomains($domains)
{
if (is_string($domains)) {
$domains = \Pimcore\Tool\Serialize::unserialize($domains);
}
$this->domains = $domains;
return $this;
}
示例15: setDataFromResource
/**
* @see Document\Tag\TagInterface::setDataFromResource
* @param mixed $data
* @return void
*/
public function setDataFromResource($data)
{
if (!empty($data)) {
$data = \Pimcore\Tool\Serialize::unserialize($data);
}
$this->id = $data["id"];
$this->type = $data["type"];
$this->poster = $data["poster"];
$this->title = $data["title"];
$this->description = $data["description"];
return $this;
}