本文整理汇总了PHP中Pimcore\Model\Object\Service::pathExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::pathExists方法的具体用法?PHP Service::pathExists怎么用?PHP Service::pathExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Object\Service
的用法示例。
在下文中一共展示了Service::pathExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: correctPath
public function correctPath()
{
// set path
if ($this->getId() != 1) {
// not for the root node
if ($this->getParentId() == $this->getId()) {
throw new \Exception("ParentID and ID is identical, an element can't be the parent of itself.");
}
$parent = AbstractObject::getById($this->getParentId());
if ($parent) {
// use the parent's path from the database here (getCurrentFullPath), to ensure the path really exists and does not rely on the path
// that is currently in the parent object (in memory), because this might have changed but wasn't not saved
$this->setPath(str_replace("//", "/", $parent->getCurrentFullPath() . "/"));
} else {
// parent document doesn't exist anymore, set the parent to to root
$this->setParentId(1);
$this->setPath("/");
}
if (strlen($this->getKey()) < 1) {
$this->setKey("---no-valid-key---" . $this->getId());
throw new \Exception("Document requires key, generated key automatically");
}
} else {
if ($this->getId() == 1) {
// some data in root node should always be the same
$this->setParentId(0);
$this->setPath("/");
$this->setKey("");
$this->setType("folder");
}
}
if (Service::pathExists($this->getFullPath())) {
$duplicate = AbstractObject::getByPath($this->getFullPath());
if ($duplicate instanceof self and $duplicate->getId() != $this->getId()) {
throw new \Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot save object");
}
}
if (strlen($this->getFullPath()) > 765) {
throw new \Exception("Full path is limited to 765 characters, reduce the length of your parent's path");
}
}
示例2: addFolderAction
public function addFolderAction()
{
$success = false;
$parent = Object::getById($this->getParam("parentId"));
if ($parent->isAllowed("create")) {
if (!Object\Service::pathExists($parent->getFullPath() . "/" . $this->getParam("key"))) {
$folder = Object\Folder::create(array("o_parentId" => $this->getParam("parentId"), "o_creationDate" => time(), "o_userOwner" => $this->user->getId(), "o_userModification" => $this->user->getId(), "o_key" => $this->getParam("key"), "o_published" => true));
$folder->setCreationDate(time());
$folder->setUserOwner($this->getUser()->getId());
$folder->setUserModification($this->getUser()->getId());
try {
$folder->save();
$success = true;
} catch (\Exception $e) {
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
}
} else {
\Logger::debug("prevented creating object id because of missing permissions");
}
$this->_helper->json(array("success" => $success));
}
示例3: pathExists
/**
* @static
* @param $type
* @param $path
* @return bool
*/
public static function pathExists($path, $type = null)
{
if ($type == "asset") {
return Asset\Service::pathExists($path);
} else {
if ($type == "document") {
return Document\Service::pathExists($path);
} else {
if ($type == "object") {
return Object\Service::pathExists($path);
}
}
}
return;
}