当前位置: 首页>>代码示例>>PHP>>正文


PHP Object_Abstract::getResource方法代码示例

本文整理汇总了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;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:18,代码来源:Service.php

示例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;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:59,代码来源:Abstract.php

示例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;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:32,代码来源:Abstract.php


注:本文中的Object_Abstract::getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。