本文整理匯總了PHP中Pimcore\Model\Document::getDao方法的典型用法代碼示例。如果您正苦於以下問題:PHP Document::getDao方法的具體用法?PHP Document::getDao怎麽用?PHP Document::getDao使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Pimcore\Model\Document
的用法示例。
在下文中一共展示了Document::getDao方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getById
/**
* Static helper to get a Document by it's id, only type Document is returned, not Document\Page, ... (see getConcreteById() )
*
* @param integer $id
* @return Document
*/
public static function getById($id)
{
$id = intval($id);
if ($id < 1) {
return null;
}
$cacheKey = "document_" . $id;
try {
$document = \Zend_Registry::get($cacheKey);
if (!$document) {
throw new \Exception("Document in registry is null");
}
} catch (\Exception $e) {
try {
if (!($document = \Pimcore\Cache::load($cacheKey))) {
$document = new Document();
$document->getDao()->getById($id);
$className = "Pimcore\\Model\\Document\\" . ucfirst($document->getType());
// this is the fallback for custom document types using prefixes
// so we need to check if the class exists first
if (!Tool::classExists($className)) {
$oldStyleClass = "Document_" . ucfirst($document->getType());
if (Tool::classExists($oldStyleClass)) {
$className = $oldStyleClass;
}
}
$document = \Pimcore::getDiContainer()->make($className);
\Zend_Registry::set($cacheKey, $document);
$document->getDao()->getById($id);
\Pimcore\Cache::save($document, $cacheKey);
} else {
\Zend_Registry::set($cacheKey, $document);
}
} catch (\Exception $e) {
\Logger::warning($e->getMessage());
return null;
}
}
if (!$document) {
return null;
}
return $document;
}
示例2: pathExists
/**
* @static
* @param $path
* @return bool
*/
public static function pathExists($path, $type = null)
{
$path = Element\Service::correctPath($path);
try {
$document = new Document();
// validate path
if (\Pimcore\Tool::isValidPath($path)) {
$document->getDao()->getByPath($path);
return true;
}
} catch (\Exception $e) {
}
return false;
}