Пример #1
0
 /**
  * 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;
 }