本文整理汇总了PHP中Pimcore\Model\Object::getDao方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getDao方法的具体用法?PHP Object::getDao怎么用?PHP Object::getDao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Object
的用法示例。
在下文中一共展示了Object::getDao方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getById
/**
* @param integer $id
* @return static
*/
public static function getById($id)
{
$id = intval($id);
if ($id < 1) {
return null;
}
$cacheKey = "object_" . $id;
try {
$object = \Zend_Registry::get($cacheKey);
if (!$object) {
throw new \Exception("Object\\AbstractObject: object in registry is null");
}
} catch (\Exception $e) {
try {
if (!($object = Cache::load($cacheKey))) {
$object = new Model\Object();
$typeInfo = $object->getDao()->getTypeById($id);
if ($typeInfo["o_type"] == "object" || $typeInfo["o_type"] == "variant" || $typeInfo["o_type"] == "folder") {
if ($typeInfo["o_type"] == "folder") {
$className = "Pimcore\\Model\\Object\\Folder";
} else {
$className = "Pimcore\\Model\\Object\\" . ucfirst($typeInfo["o_className"]);
}
$object = \Pimcore::getDiContainer()->make($className);
\Zend_Registry::set($cacheKey, $object);
$object->getDao()->getById($id);
Cache::save($object, $cacheKey);
} else {
throw new \Exception("No entry for object id " . $id);
}
} else {
\Zend_Registry::set($cacheKey, $object);
}
} catch (\Exception $e) {
\Logger::warning($e->getMessage());
return null;
}
}
// check for type
$staticType = get_called_class();
if ($staticType != 'Pimcore\\Model\\Object\\Concrete' && $staticType != 'Pimcore\\Model\\Object\\AbstractObject') {
if (!$object instanceof $staticType) {
return null;
}
}
if (!$object) {
return null;
}
return $object;
}