/**
  * 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();
 }
Example #2
1
 /**
  * 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;
 }
Example #3
0
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]);
        }
    }
}
Example #4
0
 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);
 }
Example #5
0
 public function testConstructorAndDefaultValues()
 {
     $type = $this->getAsIType();
     $actual = get_object_vars($type);
     $expected = array();
     $this->assertEquals($expected, $actual);
 }
 private function decoupleToArray($parameters)
 {
     if (is_object($parameters)) {
         $parameters = get_object_vars($parameters);
     }
     return is_array($parameters) ? array_map(__METHOD__, $parameters) : $parameters;
 }
Example #7
0
File: Xml.php Project: jncn/iRail
 /**
  * @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;
     }
 }
Example #8
0
 /**
  * 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;
 }
 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);
 }
Example #10
0
 /**
  * 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';
     }
 }
 /**
  * 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;
 }
Example #12
0
/**
 * 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;
}
 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;
 }
Example #14
0
 /**
  * @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;
     }
 }
 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;
     }
 }
Example #16
0
 public function formatObservers($object)
 {
     $result = "\nObservers \n--------------------------------------------------" . "\n";
     if (isset($object->observers)) {
         foreach ($object->observers as $item) {
             foreach (get_object_vars($item) as $name => $props) {
                 if ($name == 'commercebug_name') {
                     continue;
                 }
                 if (!is_object($props)) {
                     continue;
                 }
                 $info = array();
                 $info[] = $name;
                 unset($props->args);
                 $info = array_merge($info, (array) $props);
                 Pzdgmailcom_Commercebug_Model_Shim::Log('Mage2 refactoring needed at ' . __CLASS__ . ' ' . __LINE__);
                 unset($info['config']);
                 $result .= implode("\t", $info) . "\n";
             }
         }
     }
     $this->_info[] = $result;
     return $this;
 }
Example #17
0
 public function save()
 {
     $values = get_object_vars($this);
     $filtered = null;
     foreach ($values as $key => $value) {
         if ($value !== null && $value !== '' && strpos($key, 'obj_') === false && $key !== 'id') {
             if ($value === false) {
                 $value = 0;
             }
             $filtered[$key] = $value;
         }
     }
     $columns = array_keys($filtered);
     if ($this->id) {
         $columns = join(" = ?, ", $columns);
         $columns .= ' = ?';
         $query = "UPDATE " . static::$table . " SET {$columns} WHERE id =" . $this->id;
     } else {
         $params = join(", ", array_fill(0, count($columns), "?"));
         $columns = join(", ", $columns);
         $query = "INSERT INTO " . static::$table . " ({$columns}) VALUES ({$params})";
     }
     $result = self::$database->execute($query, null, $filtered);
     if ($result) {
         $result = array('error' => false, 'message' => self::$database->getInsertedID());
     } else {
         $result = array('error' => true, 'message' => self::$database->getError());
     }
     return $result;
 }
 /**
  * Connect to the database
  *
  * @param string $dbType Database adapter type for Zend_Db
  * @param array|object $dbDescription Adapter-specific connection settings
  * @return Zend_Db_Adapter_Abstract
  * @see Zend_Db::factory()
  */
 protected function _connect($dbType, $dbDescription)
 {
     if (is_object($dbDescription)) {
         $dbDescription = get_object_vars($dbDescription);
     }
     return Zend_Db::factory($dbType, $dbDescription);
 }
 public function process()
 {
     $list = erLhcoreClassChat::getList(array('limit' => 100, 'filterlt' => array('time' => $this->range_to), 'filtergt' => array('time' => $this->range_from)));
     self::$archiveTable = "lh_chat_archive_{$this->id}";
     self::$archiveMsgTable = "lh_chat_archive_msg_{$this->id}";
     $pending_archive = count($list);
     $messagesArchived = 0;
     $firstChatID = 0;
     $lastChatID = 0;
     foreach ($list as $item) {
         if ($firstChatID == 0) {
             $firstChatID = $item->id;
         }
         $archive = new erLhcoreClassModelChatArchive();
         $archive->setState(get_object_vars($item));
         $archive->id = null;
         $archive->saveThis();
         $messages = erLhcoreClassModelmsg::getList(array('limit' => 1000, 'filter' => array('chat_id' => $item->id)));
         $messagesArchived += count($messages);
         foreach ($messages as $msg) {
             $msgArchive = new erLhcoreClassModelChatArchiveMsg();
             $msgArchive->setState(get_object_vars($msg));
             $msgArchive->id = null;
             $msgArchive->chat_id = $archive->id;
             erLhcoreClassChat::getSession()->save($msgArchive);
         }
         $lastChatID = $item->id;
         $item->removeThis();
     }
     return array('error' => 'false', 'fcid' => $firstChatID, 'lcid' => $lastChatID, 'messages_archived' => $messagesArchived, 'chats_archived' => count($list), 'pending_archive' => $pending_archive == 100 ? 'true' : 'false');
 }
 /**
  * update function
  * @param Invoice $invoice
  * @return object
  * @throws ShopException
  */
 public function update(Invoice $invoice)
 {
     if (!is_numeric($invoice->order_srl)) {
         throw new ShopException('You must specify a srl for the updated invoice');
     }
     return $this->query('updateInvoice', get_object_vars($invoice));
 }
Example #21
0
 /**
  * Return an Array of Object attributes.
  *
  * @param Mixed $data
  * @return Array
  */
 protected function _prepareData($data)
 {
     if (is_object($data)) {
         $arr = get_object_vars($data);
         foreach ($arr as $key => $value) {
             $assocArr = array();
             if (is_array($value)) {
                 foreach ($value as $v) {
                     if (is_object($v) && count(get_object_vars($v)) == 2 && isset($v->key) && isset($v->value)) {
                         $assocArr[$v->key] = $v->value;
                     }
                 }
             }
             if (!empty($assocArr)) {
                 $arr[$key] = $assocArr;
             }
         }
         $arr = $this->_prepareData($arr);
         return parent::_prepareData($arr);
     }
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             if (is_object($value) || is_array($value)) {
                 $data[$key] = $this->_prepareData($value);
             } else {
                 $data[$key] = $value;
             }
         }
         return parent::_prepareData($data);
     }
     return $data;
 }
Example #22
0
 public function login($identity, $duration = 0)
 {
     if (!$this->_checkMod($identity->role)) {
         return false;
     }
     //::app()->session['loginrole']=$identity->role;
     //var_dump(Yii::app()->session);exit;
     $id = $identity->getId();
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($id, $states, false)) {
         $this->changeIdentity($id, $identity->getName(), get_object_vars($identity));
         if ($duration > 0) {
             if ($this->allowAutoLogin) {
                 $this->saveToCookie($duration);
             } else {
                 throw new CException(Yii::t('yii', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
             }
         }
         if ($this->absoluteAuthTimeout) {
             $this->setState(self::AUTH_ABSOLUTE_TIMEOUT_VAR, time() + $this->absoluteAuthTimeout);
         }
         $this->afterLogin(false);
     }
     return !$this->getIsGuest();
 }
Example #23
0
 /**
  * Hydrate this instance from a response object
  * @param \stdClass $object
  */
 public function hydrate(\stdClass $object)
 {
     $data = get_object_vars($object);
     foreach ($data as $key => $value) {
         $this->{$key} = $value;
     }
 }
/**
 * Replace property_exists()
 *
 * @category    PHP
 * @package     PHP_Compat
 * @license     LGPL - http://www.gnu.org/licenses/lgpl.html
 * @copyright   2004-2007 Aidan Lister <*****@*****.**>, Arpad Ray <*****@*****.**>
 * @link        http://php.net/property_exists
 * @author      Christian Stadler <*****@*****.**>
 * @version     $Revision: 269597 $
 * @since       PHP 5.1.0
 * @require     PHP 4.0.0 (user_error)
 */
function php_compat_property_exists($class, $property)
{
    if (!is_string($property)) {
        user_error('property_exists() expects parameter 2 to be a string, ' . gettype($property) . ' given', E_USER_WARNING);
        return false;
    }
    if (is_object($class) || is_string($class)) {
        if (is_string($class)) {
            if (!class_exists($class)) {
                return false;
            }
            $vars = get_class_vars($class);
        } else {
            $vars = get_object_vars($class);
        }
        // Bail out early if get_class_vars or get_object_vars didnt work
        // or returned an empty array
        if (!is_array($vars) || count($vars) <= 0) {
            return false;
        }
        $property = strtolower($property);
        foreach (array_keys($vars) as $varname) {
            if (strtolower($varname) == $property) {
                return true;
            }
        }
        return false;
    }
    user_error('property_exists() expects parameter 1 to be a string or ' . 'an object, ' . gettype($class) . ' given', E_USER_WARNING);
    return false;
}
 public function __sleep()
 {
     if ($this->oCurrentLanguageObject !== null) {
         $this->oCurrentLanguageObject = $this->oCurrentLanguageObject->getId();
     }
     return array_keys(get_object_vars($this));
 }
 private function has_attribute($attribute)
 {
     // get object_vars return an associative array with all attributes
     $object_vars = get_object_vars($this);
     // will not care the value only whether the key is exists
     return array_key_exists($attribute, $object_vars);
 }
Example #27
0
 public function editAction()
 {
     $tenantName = $this->getClient()->getConfig()->getTenantName();
     $listDns = array();
     foreach ($this->getClient()->contrail->listVirtualDns() as $item) {
         $listDns[] = implode(':', $item->fq_name);
     }
     $ipams = array();
     foreach ($this->getClient()->contrail->listIpam() as $item) {
         $item = get_object_vars($item);
         if ($item['fq_name'][1] == $tenantName) {
             $a = $item['fq_name'];
             array_shift($a);
             $item['name'] = implode(':', $a);
         } else {
             $item['name'] = implode(':', $item['fq_name']);
         }
         $ipams[] = $item;
     }
     if ($this->getParam('dnsId')) {
         $dns = $this->getClient()->contrail->listVirtualDns($this->getParam('dnsId'));
     } else {
         $dns = null;
     }
     $this->response->page('ui/tools/openstack/contrail/dns/create.js', array('listDns' => $listDns, 'dns' => $dns, 'ipams' => $ipams, 'fqBaseName' => array('default-domain')), array('ux-boxselect.js'));
 }
Example #28
0
 /**
  * @param mixed            $value
  * @param AbstractPlatform $platform
  *
  * @return string
  * @throws \InvalidArgumentException
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return '';
     }
     if ($value instanceof \stdClass) {
         $value = get_object_vars($value);
     }
     if (!is_array($value)) {
         throw new \InvalidArgumentException("Hstore value must be off array or \\stdClass.");
     }
     $hstoreString = '';
     foreach ($value as $k => $v) {
         if (!is_string($v) && !is_numeric($v) && !is_bool($v)) {
             throw new \InvalidArgumentException("Cannot save 'nested arrays' into hstore.");
         }
         $v = trim($v);
         if (!is_numeric($v) && false !== strpos($v, ' ')) {
             $v = sprintf('"%s"', $v);
         }
         $hstoreString .= "{$k} => {$v}," . "\n";
     }
     $hstoreString = substr(trim($hstoreString), 0, -1) . "\n";
     return $hstoreString;
 }
 /**
  * Returns an array of public variable names (instead of properties names of parent class)
  *
  * @return array
  */
 public function getPublicProperties()
 {
     // return $this->table->getPublicProperties();
     return array_filter(array_keys(get_object_vars($this)), function ($k) {
         return substr($k, 0, 1) != '_';
     });
 }
Example #30
-1
 protected function setDataFromArray($data)
 {
     foreach (get_object_vars($this) as $name => $defaultValue) {
         $property = new ReflectionProperty(get_class($this), $name);
         if (!$property->isPublic()) {
             continue;
         }
         preg_match("/@var[ ]+([\\w\\\\\\[\\]]+)/", $property->getDocComment(), $matches);
         $type = !empty($matches) ? $matches[1] : false;
         if (empty($type)) {
             continue;
         }
         preg_match("/@null/", $property->getDocComment(), $matches);
         $isNullable = !empty($matches);
         $restrictions = [];
         preg_match("/@(inArray(\\[(.*)\\]))/", $property->getDocComment(), $matches);
         if (!empty($matches) && in_array($type, ['string', 'int'])) {
             eval("\$parsedData = {$matches[2]};");
             if (!is_array($parsedData)) {
                 throw new Exception(get_class($this) . ": Invalid syntax in {$name} tag @inArray{$matches[2]}", Exception::INTERNAL_ERROR);
             }
             $restrictions = $parsedData;
         }
         $this->{$name} = Helper::bringValueToType($this, $type, isset($data[$name]) ? $data[$name] : $defaultValue, $isNullable, $restrictions);
     }
 }