Esempio n. 1
0
 /**
  * Set the prefix for all upcoming set()/update() requests, based on a friendly section name (like 'dialplan' or 'directory')
  * Use this helper method to set the section the subsequent set()/update() requests should go to. This does two things:
  *   1) Prevents having to add a big long xpath to every set/update request
  *   2) Hides some of the uglyness in deeply nested XML elements within the FreeSWITCH config, so that we closer resemble
  *      the stock samples that come with FreeSWITCH so people are more comfortable using our helper methods
  *
  * Usage is:
  *   FreeSwitch::setSection('dialplan');
  *   FreeSwitch::getInstance()->xml->set('/mysetting');
  *
  * Note that sprintf is utilized to populate any additional variables you pass into the section XPath (if the xpath supports it).
  * So an alternate usage for users:
  *   FreeSwitch::setSection('users', 'mysystem.com', 'bob');
  *
  * Would allow for setting/getting variables for the domain 'mysystem.com' and user named bob in our users directory.
  *
  * @param string $sectionName Shortname of the section we want to work with
  * @return FsDomDocument Return the FsDomDocument element with the prefix now set for us (normally you ignore this returned var)
  */
 public static function setSection($sectionName)
 {
     $args = func_get_args();
     array_shift($args);
     if ($args) {
         self::$instance->xml->setXmlRoot(vsprintf(self::$sectionPaths[$sectionName], $args));
     } else {
         self::$instance->xml->setXmlRoot(self::$sectionPaths[$sectionName]);
     }
     if ($sectionName == 'netlist') {
         self::$aclDirty = TRUE;
     }
     if ($sectionName == 'sofia' or $sectionName == 'gateway') {
         self::$sofiaDirty = TRUE;
     }
     if ($sectionName == 'xmlcdr') {
         self::$xmlcdrDirty = TRUE;
     }
     // This probably isn't necessary. Could just return nothing.
     return self::$instance->xml;
 }