本文整理汇总了PHP中Object_Abstract::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Object_Abstract::getResource方法的具体用法?PHP Object_Abstract::getResource怎么用?PHP Object_Abstract::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object_Abstract
的用法示例。
在下文中一共展示了Object_Abstract::getResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pathExists
/**
* @static
* @param $path
* @return bool
*/
public static function pathExists($path, $type = null)
{
$path = Element_Service::correctPath($path);
try {
$object = new Object_Abstract();
if (Pimcore_Tool::isValidPath($path)) {
$object->getResource()->getByPath($path);
return true;
}
} catch (Exception $e) {
}
return false;
}
示例2: getById
/**
* @param integer $id
* @return Object_Abstract
*/
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_Abstract: object in registry is null");
}
} catch (Exception $e) {
try {
if (!($object = Pimcore_Model_Cache::load($cacheKey))) {
$object = new Object_Abstract();
$typeInfo = $object->getResource()->getTypeById($id);
if ($typeInfo["o_type"] == "object" || $typeInfo["o_type"] == "variant" || $typeInfo["o_type"] == "folder") {
if ($typeInfo["o_type"] == "folder") {
$concreteClassName = "Object_Folder";
} else {
$concreteClassName = "Object_" . ucfirst($typeInfo["o_className"]);
}
// check for a mapped class
$concreteClassName = Pimcore_Tool::getModelClassMapping($concreteClassName);
$object = new $concreteClassName();
Zend_Registry::set($cacheKey, $object);
$object->getResource()->getById($id);
Pimcore_Model_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);
return null;
}
}
$selfType = get_class();
$staticType = get_called_class();
// check for type
if ($selfType != $staticType) {
if (get_class($object) != $staticType) {
if (!($object instanceof Object_Concrete && $staticType == "Object_Concrete")) {
return null;
}
}
}
if (!$object) {
return null;
}
return $object;
}
示例3: sanityCheck
/**
* Checks if data for this field is valid and removes broken dependencies
*
* @param Object_Abstract $object
* @return bool
*/
public function sanityCheck($object)
{
$sane = true;
$name = $this->getName();
$getter = "get" . ucfirst($name);
$data = $object->{$getter}();
$objectRelationIds = array();
if (is_array($data)) {
foreach ($data as $o) {
if ($o instanceof Element_Interface) {
$objectRelationIds[] = $o->getId();
}
}
} else {
if ($data instanceof Element_Interface) {
$objectRelationIds[] = $data->getId();
}
}
$resourceRelationIds = $object->getResource()->getRelationIds($this->getName());
$diff = array_diff($objectRelationIds, $resourceRelationIds);
if (count($diff) > 0) {
$sane = false;
Logger::notice("Detected insane relation(s), removing reference to non existent elements with ids [" . implode(',', $diff) . "]");
}
return $sane;
}