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


PHP get_object_vars函数代码示例

本文整理汇总了PHP中get_object_vars函数的典型用法代码示例。如果您正苦于以下问题:PHP get_object_vars函数的具体用法?PHP get_object_vars怎么用?PHP get_object_vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_object_vars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Setup the config based on either the Configure::read() values
  * or the PaypalIpnConfig in config/paypal_ipn_config.php
  *
  * Will attempt to read configuration in the following order:
  *   Configure::read('PaypalIpn')
  *   App::import() of config/paypal_ipn_config.php
  *   App::import() of plugin's config/paypal_ipn_config.php
  */
 function __construct()
 {
     $this->config = Configure::read('PaypalIpn');
     if (empty($this->config)) {
         $importConfig = array('type' => 'File', 'name' => 'PaypalIpn.PaypalIpnConfig', 'file' => CONFIGS . 'paypal_ipn_config.php');
         if (!class_exists('PaypalIpnConfig')) {
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             // Import from paypal plugin configuration
             $importConfig['file'] = 'config' . DS . 'paypal_ipn_config.php';
             App::import($importConfig);
         }
         if (!class_exists('PaypalIpnConfig')) {
             trigger_error(__d('paypal_ipn', 'PaypalIpnConfig: The configuration could not be loaded.', true), E_USER_ERROR);
         }
         if (!PHP5) {
             $config =& new PaypalIpnConfig();
         } else {
             $config = new PaypalIpnConfig();
         }
         $vars = get_object_vars($config);
         foreach ($vars as $property => $configuration) {
             if (strpos($property, 'encryption_') === 0) {
                 $name = substr($property, 11);
                 $this->encryption[$name] = $configuration;
             } else {
                 $this->config[$property] = $configuration;
             }
         }
     }
     parent::__construct();
 }
开发者ID:ranium,项目名称:CakePHP-Paypal-IPN-Plugin,代码行数:42,代码来源:paypal.php

示例2: json_nukeempty

function json_nukeempty(&$data)
{
    if (gettype($data) == 'object') {
        $data = get_object_vars($data);
    }
    if (!is_array($data)) {
        return;
    }
    foreach ($data as $key => $dummy) {
        if (gettype($data[$key]) == 'string') {
            if ($dummy === "") {
                unset($data[$key]);
            }
            continue;
        }
        if (gettype($data[$key]) == 'object') {
            $data[$key] = get_object_vars($data[$key]);
        }
        if (!is_array($data[$key])) {
            continue;
        }
        if (count($data[$key]) > 0) {
            json_nukeempty($data[$key]);
        }
        if (count($data[$key]) == 0) {
            unset($data[$key]);
        }
    }
}
开发者ID:patrickz98,项目名称:xavaro,代码行数:29,代码来源:json.php

示例3: testFormatJson

 public function testFormatJson()
 {
     $server = ['HTTP_ACCEPT' => 'application/json', 'REQUEST_METHOD' => 'GET', 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename', 'REQUEST_URI' => 'my/base/path/my/request/uri', 'PHP_SELF' => 'my/base/path'];
     $request = new Request(["callback" => ""], [], [], [], [], $server);
     $apiResult = new Result($request);
     $return = $apiResult->createResponse()->getContent();
     $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
     $response = json_decode($return);
     $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response);
     $this->assertObjectHasAttribute("meta", $response);
     $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->meta);
     $this->assertObjectHasAttribute("response", $response);
     $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->response);
     $this->assertEquals(0, sizeof(get_object_vars($response->response)));
     $this->assertEquals(0, sizeof(get_class_methods($response->response)));
     $this->checkResponseFieldMeta($response, "api_version", V1::VERSION, \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     $this->checkResponseFieldMeta($response, "request", "GET my/base/path/my/request/uri", \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     $date = new \DateTime();
     $now = $date->format('U');
     $dateQuery = \DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
     $nowQuery = $dateQuery->format('U');
     $this->assertLessThan(1, $nowQuery - $now);
     $this->assertDateAtom($response->meta->response_time);
     $date = new \DateTime();
     $nowU = $date->format('U');
     $dateResp = \DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
     $respU = $dateResp->format('U');
     $this->assertLessThan(3, abs($respU - $nowU), 'No more than 3sec between now and the query');
     $this->checkResponseFieldMeta($response, "http_code", 200, \PHPUnit_Framework_Constraint_IsType::TYPE_INT);
     $this->checkResponseFieldMeta($response, "charset", "UTF-8", \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
     $this->assertObjectHasAttribute("error_message", $response->meta);
     $this->assertNull($response->meta->error_message);
     $this->assertObjectHasAttribute("error_details", $response->meta);
     $this->assertNull($response->meta->error_details);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:35,代码来源:ResultTest.php

示例4: XMLAppend

 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }
开发者ID:KVSun,项目名称:core_api,代码行数:40,代码来源:xmlappend.php

示例5: testConstructorAndDefaultValues

 public function testConstructorAndDefaultValues()
 {
     $type = $this->getAsIType();
     $actual = get_object_vars($type);
     $expected = array();
     $this->assertEquals($expected, $actual);
 }
开发者ID:grimmlink,项目名称:podata,代码行数:7,代码来源:Int16Test.php

示例6: decoupleToArray

 private function decoupleToArray($parameters)
 {
     if (is_object($parameters)) {
         $parameters = get_object_vars($parameters);
     }
     return is_array($parameters) ? array_map(__METHOD__, $parameters) : $parameters;
 }
开发者ID:dmeikle,项目名称:gossamerCMS-application,代码行数:7,代码来源:UnicodeHandler.php

示例7: startObject

 /**
  * @param $name
  * @param $object
  * @return mixed|void
  */
 public function startObject($name, $object)
 {
     // Test wether this object is a first-level array object
     echo "<{$name}";
     if ($this->currentarrayindex > -1 && $this->stack[$this->currentarrayindex] == $name && $name != 'station') {
         echo ' id="' . $this->arrayindices[$this->currentarrayindex] . '"';
     }
     // fallback for attributes and name tag
     $hash = get_object_vars($object);
     $named = '';
     foreach ($hash as $elementkey => $elementval) {
         if (in_array($elementkey, $this->ATTRIBUTES)) {
             if ($elementkey == '@id') {
                 $elementkey = 'URI';
             }
             if ($elementkey == 'normal' || $elementkey == 'canceled') {
                 $elementval = intval($elementval);
             }
             echo " {$elementkey}=\"{$elementval}\"";
         } elseif ($elementkey == 'name') {
             $named = $elementval;
         }
     }
     echo '>';
     if ($named != '') {
         echo $named;
     }
 }
开发者ID:jncn,项目名称:iRail,代码行数:33,代码来源:Xml.php

示例8: __call

 /**
  * Interceptor for all interfaces
  *
  * @param string $function
  * @param array $args
  */
 public function __call($function, $args)
 {
     $args = $args[0];
     /** @var Mage_Api_Helper_Data */
     $helper = Mage::helper('api/data');
     $helper->wsiArrayUnpacker($args);
     $args = get_object_vars($args);
     if (isset($args['sessionId'])) {
         $sessionId = $args['sessionId'];
         unset($args['sessionId']);
     } else {
         // Was left for backward compatibility.
         $sessionId = array_shift($args);
     }
     $apiKey = '';
     $nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
     foreach ($nodes as $resource => $prefix) {
         $prefix = $prefix->asArray();
         if (false !== strpos($function, $prefix)) {
             $method = substr($function, strlen($prefix));
             $apiKey = $resource . '.' . strtolower($method[0]) . substr($method, 1);
         }
     }
     list($modelName, $methodName) = $this->_getResourceName($apiKey);
     $methodParams = $this->getMethodParams($modelName, $methodName);
     $args = $this->prepareArgs($methodParams, $args);
     $res = $this->call($sessionId, $apiKey, $args);
     $obj = $helper->wsiArrayPacker($res);
     $stdObj = new stdClass();
     $stdObj->result = $obj;
     return $stdObj;
 }
开发者ID:Airmal,项目名称:Magento-Em,代码行数:38,代码来源:Handler.php

示例9: saveWizard

 function saveWizard()
 {
     global $toC_Json, $osC_Language, $osC_Database;
     $error = false;
     $configurations = $toC_Json->decode($_REQUEST['data']);
     foreach ($configurations as $index => $configurations) {
         $configuration = get_object_vars($configurations);
         foreach ($configuration as $key => $value) {
             $Qupdate = $osC_Database->query('update :table_configuration set configuration_value = :configuration_value, last_modified = now() where configuration_key = :configuration_key');
             $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
             $Qupdate->bindValue(':configuration_value', $value);
             $Qupdate->bindValue(':configuration_key', $key);
             $Qupdate->execute();
             if ($osC_Database->isError()) {
                 $error = true;
                 break;
             }
         }
     }
     if ($error === false) {
         require_once 'includes/classes/desktop_settings.php';
         $toC_Desktop_Settings = new toC_Desktop_Settings();
         $toC_Desktop_Settings->setWizardComplete();
         $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
         osC_Cache::clear('configuration');
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
     }
     echo $toC_Json->encode($response);
 }
开发者ID:4DvAnCeBoY,项目名称:tomatocart-shoppingcart,代码行数:30,代码来源:configuration_wizard.php

示例10: calculateType

 /**
  * Try to figure out what type our data has.
  */
 function calculateType()
 {
     if ($this->data === true || $this->data === false) {
         return 'boolean';
     }
     if (is_integer($this->data)) {
         return 'int';
     }
     if (is_double($this->data)) {
         return 'double';
     }
     // Deal with XMLRPC object types base64 and date
     if (is_object($this->data) && $this->data instanceof XMLRPC_Date) {
         return 'date';
     }
     if (is_object($this->data) && $this->data instanceof XMLRPC_Base64) {
         return 'base64';
     }
     // If it is a normal PHP object convert it in to a struct
     if (is_object($this->data)) {
         $this->data = get_object_vars($this->data);
         return 'struct';
     }
     if (!is_array($this->data)) {
         return 'string';
     }
     /* We have an array - is it an array or a struct ? */
     if ($this->isStruct($this->data)) {
         return 'struct';
     } else {
         return 'array';
     }
 }
开发者ID:BackupTheBerlios,项目名称:btg-svn,代码行数:36,代码来源:xmlrpc.php

示例11: get_post_type

 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  * @return type Description.
  */
 public function get_post_type($post_type_slug)
 {
     if (empty($post_type_slug)) {
         return wpcf_custom_types_default();
     }
     $post_type = array();
     $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
     if (isset($custom_types[$post_type_slug])) {
         $post_type = $custom_types[$post_type_slug];
         $post_type['update'] = true;
     } else {
         $buildin_post_types = wpcf_get_builtin_in_post_types();
         if (isset($buildin_post_types[$post_type_slug])) {
             $post_type = get_object_vars(get_post_type_object($post_type_slug));
             $post_type['labels'] = get_object_vars($post_type['labels']);
             $post_type['slug'] = esc_attr($post_type_slug);
             $post_type['_builtin'] = true;
         } else {
             return false;
         }
     }
     if (!isset($post_type['update'])) {
         $post_type['update'] = false;
     }
     return $post_type;
 }
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:43,代码来源:class.types.admin.post-type.php

示例12: dol_json_encode

/**
 * Implement json_encode for PHP that does not support it
 *
 * @param	mixed	$elements		PHP Object to json encode
 * @return 	string					Json encoded string
 * @deprecated PHP >= 5.3 supports native json_encode
 * @see json_encode()
 */
function dol_json_encode($elements)
{
    dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING);
    $num = count($elements);
    if (is_object($elements)) {
        $num = 0;
        foreach ($elements as $key => $value) {
            $num++;
        }
    }
    //var_dump($num);
    // determine type
    if (is_numeric(key($elements)) && key($elements) == 0) {
        // indexed (list)
        $keysofelements = array_keys($elements);
        // Elements array mus have key that does not start with 0 and end with num-1, so we will use this later.
        $output = '[';
        for ($i = 0, $last = $num - 1; $i < $num; $i++) {
            if (!isset($elements[$keysofelements[$i]])) {
                continue;
            }
            if (is_array($elements[$keysofelements[$i]]) || is_object($elements[$keysofelements[$i]])) {
                $output .= json_encode($elements[$keysofelements[$i]]);
            } else {
                $output .= _val($elements[$keysofelements[$i]]);
            }
            if ($i !== $last) {
                $output .= ',';
            }
        }
        $output .= ']';
    } else {
        // associative (object)
        $output = '{';
        $last = $num - 1;
        $i = 0;
        $tmpelements = array();
        if (is_array($elements)) {
            $tmpelements = $elements;
        }
        if (is_object($elements)) {
            $tmpelements = get_object_vars($elements);
        }
        foreach ($tmpelements as $key => $value) {
            $output .= '"' . $key . '":';
            if (is_array($value)) {
                $output .= json_encode($value);
            } else {
                $output .= _val($value);
            }
            if ($i !== $last) {
                $output .= ',';
            }
            ++$i;
        }
        $output .= '}';
    }
    // return
    return $output;
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:68,代码来源:json.lib.php

示例13: recursive

 function recursive(&$data)
 {
     $out = array();
     $result = null;
     if (is_object($data)) {
         $array = get_object_vars($data);
         foreach ($array as $key => $value) {
             if (is_object($value)) {
                 $out[$key] = $this->recursive($value);
             } else {
                 if (is_array($value)) {
                     $out[$key] = $this->recursive($value);
                 }
             }
         }
         if (empty($out)) {
             $out = $this->AmfCallback->encode($data);
         }
     } else {
         if (is_array($data)) {
             return $data;
         }
     }
     return $out;
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:25,代码来源:amf_callback.test.php

示例14: update

 /**
  * @throws \Exception
  */
 public function update()
 {
     try {
         $ts = time();
         $this->model->setModificationDate($ts);
         $type = get_object_vars($this->model);
         foreach ($type as $key => $value) {
             if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_KEYS))) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
                 if (is_array($value) || is_object($value)) {
                     if ($this->model->getType() == 'select') {
                         $value = \Zend_Json::encode($value);
                     } else {
                         $value = \Pimcore\Tool\Serialize::serialize($value);
                     }
                 }
                 $data[$key] = $value;
             }
         }
         $this->db->update(self::TABLE_NAME_KEYS, $data, $this->db->quoteInto("id = ?", $this->model->getId()));
         return $this->model;
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:30,代码来源:Dao.php

示例15: getcomboAction

 public function getcomboAction()
 {
     try {
         $EntityManagerPlugin = $this->EntityManagerPlugin();
         $CalidadBO = new CalidadBO();
         $CalidadBO->setEntityManager($EntityManagerPlugin->getEntityManager());
         $SesionUsuarioPlugin = $this->SesionUsuarioPlugin();
         $SesionUsuarioPlugin->isLogin();
         $body = $this->getRequest()->getContent();
         $json = json_decode($body, true);
         //var_dump($json); exit;
         $texto_primer_elemento = $json['texto_primer_elemento'];
         $calidad_id = null;
         $opciones = $CalidadBO->getComboCalidad($calidad_id, $texto_primer_elemento);
         $response = new \stdClass();
         $response->opciones = $opciones;
         $response->respuesta_code = 'OK';
         $json = new JsonModel(get_object_vars($response));
         return $json;
     } catch (\Exception $e) {
         $excepcion_msg = utf8_encode($this->ExcepcionPlugin()->getMessageFormat($e));
         $response = $this->getResponse();
         $response->setStatusCode(500);
         $response->setContent($excepcion_msg);
         return $response;
     }
 }
开发者ID:blackhack123,项目名称:DISPO-AGRINAG,代码行数:27,代码来源:CalidadController.php


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