Пример #1
0
 /**
  * 获取对象的字段数据
  * @param fixed $obj
  * @param string $callback_fun
  * @return fixed 返回字段数据
  */
 public static function get_object_field_data($obj, $callback_fun = null)
 {
     if ($callback_fun) {
         $data = $obj->{$callback_fun}();
     } elseif ($obj instanceof \OOP_ORM_Data) {
         $data = $obj->get_field_data();
     } elseif ($obj instanceof \stdClass) {
         $data = (array) $obj;
     } elseif ($obj instanceof \OOP_ORM) {
         # OOP_ORM对象无法作用于实际数据
         return false;
     } elseif (\method_exists($obj, 'getArrayCopy')) {
         $data = $obj->getArrayCopy();
     } elseif (\method_exists($obj, '__toString')) {
         $data = $obj->__toString();
     } else {
         # 对于未知且没有设置回调方法的对象,返回get_object_vars()结果
         return \get_object_vars($obj);
     }
     return $data;
 }
Пример #2
0
/**
 * setting for disable feed cache
 * @param fixed $feed
 * @return none
 */
function do_not_cache_feeds(&$feed)
{
    $feed->enable_cache(false);
}