/** * Verify setOptions can merge a Cpanel_Core_Object into itself without overwriting * @depends testSetOptions * @depends testGetAllDataRecursively */ public function testSetOptionsCanMergeCpanelObjectWithoutOverwritting() { $arr1 = array('a' => 1, 'b' => array('bb' => 2)); $arr2 = array('a' => '11', 'b' => array('bb' => 22, 'BB' => 22), 'c' => 3); $expected = array('a' => 11, 'b' => array('bb' => 22, 'BB' => 22), 'c' => 3); $cpObj = new Cpanel_Core_Object($arr2); $cpObj->setOptions(new Cpanel_Core_Object($arr1), false); $this->assertEquals($expected, $cpObj->getAllDataRecursively()); }
/** * Constructor * * @param array $optsArray Option configuration data * * @return Cpanel_Service_Abstract */ public function __construct($optsArray = array()) { parent::__construct($optsArray); if (!$this->listner) { Cpanel_Listner_Observer_GenericLogger::initLogger($this, 1, array('level' => 'std')); } return $this; }
/** * Constructor * * By default, Cpanel_Parser_LiveJSON::CONDENSED_MODE will be set * * @param arrays $optsArray Optional configuration data * * @return Cpanel_Parser_LiveJSON */ public function __construct($optsArray = array()) { parent::__construct($optsArray); $mode = $this->getOption('mode'); $this->setMode(self::CONDENSED_MODE); if ($mode) { $this->setMode($mode); } return $this; }
/** * Retrieve the Service namespace from given array or config, if one exists * * If the Cpanel config convention is utilized, a successful return will * provide a Cpanel_Core_Object which should have a key/namespace * 'config'. If the $type is not found, the general service namespace will * be returned (which may also have the 'config' namespace). * * @param string $type The named service type to retrieve * @param Cpanel_Core_Object $optsArray Cpanel config to search within * * @return Cpanel_Core_Object|array Emtpy array if $type or $optsArray is * empty, otherwise the expected configuration data */ public static function getServiceConfig($type, $optsArray) { $opts = $optsArray; // return empty array if called without 'blank' $type or $optsArray // due to inherent complexity with configs, this makes customized configs // easier to deal with if (empty($type) || empty($opts)) { return array(); } //convert to Cpanel_Core_Object if not already if (!$opts instanceof Cpanel_Core_Object) { $opts = new Cpanel_Core_Object($opts); } //traverse into 'cpanel' namespace if present $base = $opts->getOption('cpanel'); if (!empty($base)) { $opts = $base; } // traverse into 'service' namespace if present $base = $opts->getOption('service'); if (!empty($base)) { $opts = $base; } //source out requested $type namespace $base = $opts->getOption($type); // if requested $type wasn't found, return the default service namespace if (!empty($base)) { $opts = $base; } return $opts; }
/** * Cosntructor * * @param Cpanel_Query_Object $rObj Response object * * @return Cpanel_Query_Http_Abstract * @throws Exception If $rObj is an invalid query/response object */ public function __construct($rObj = '') { parent::__construct(); if ($rObj) { if (!$rObj instanceof Cpanel_Query_Object) { throw new Exception('Invalid QueryObject'); } $this->setResponseObject($rObj); } return $this; }
/** * Constructor * * By default, Cpanel_Parser_XML::DOM_MODE will be set. As well, * all errors warnings generated by LibXML will be suppressed. This errors * well be collected later, in the event of a decode error. * * @param arrays $optsArray Optional configuration data * * @return Cpanel_Parser_XML */ public function __construct($optsArray = array()) { parent::__construct($optsArray); $libErrMode = (bool) (!$this->disableSuppressLibXML); libxml_use_internal_errors($libErrMode); $mode = $this->mode; $this->setMode(self::DOM_MODE); if ($mode) { $this->setMode($mode); } return $this; }
/** * Constructor * * This constructor will define a shutdown function. This helps ensure the * cpsrvd receives the proper shutdown notification and the socket file is * properly closed. See {@link closeCpanelHandle()} * * @param Cpanel_Query_Object $rObj Optionally attach the response * object at instantiation. * * @return Cpanel_Query_Live_Abstract */ public function __construct($rObj = '') { parent::__construct(); if ($rObj) { if (!$rObj instanceof Cpanel_Query_Object) { throw new Exception('Invalid QueryObject'); } $this->setResponseObject($rObj); } if (!$this->socketTimeout) { $this->socketTimeout = self::SOCKET_TIMEOUT; } register_shutdown_function(array($this, 'closeCpanelHandle')); return $this; }
/** * Constructor * * @param arrays $optsArray Optional configuration data * * @return Cpanel_Query_Object */ public function __construct($optsArray = array()) { parent::__construct($optsArray); $this->_query = new Cpanel_Core_Object(); //TODO: make response an arrayobject with magic accessors? $this->_response = new Cpanel_Core_Object(); //@todo make meths of this? $this->_pinterface = 'Cpanel_Parser_Interface'; $this->_outputFormat = $this->_defaultOutputFormat; return $this; }
/** * Constructor * * Passing 'level'=>$value in configuration data array will set the logger's * verbosity level. Verbosity levels response to specific types of logged * messages generated by the log listner. Valid verbosity levels are: * 'loud' - will response to any logged message * 'verbose' - will response to 'info', 'warn' and 'die' messages * 'std' - will only response to 'warn' and 'die' messages * 'quiet' - will only response to 'die' messages * 'silent' - will never log any messages * * @param array $optArray Optional configuration data * * @return Cpanel_Listner_Observer_GenericLogger */ public function __construct($optArray = array()) { //TODO: break this out into methods $this->_levelkey = array('loud' => array('debug', 'info', 'warn', 'die'), 'verbose' => array('info', 'warn', 'die'), 'std' => array('warn', 'die'), 'quiet' => array('die'), 'silent' => array()); if (!array_key_exists('level', $optArray)) { $optArray['level'] = 'std'; } $tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC'; date_default_timezone_set($tz); parent::__construct($optArray); return $this; }