Exemplo n.º 1
0
 /**
  * Get the setup configuration
  * 
  * 
  * @return ArrayObject
  */
 public static function getSetup($id)
 {
     $setup = "";
     $services = array();
     $panel = Isp::getPanel();
     $records = Doctrine_Query::create()->from('OrdersItems oi')->leftJoin('oi.Products p')->where('oi.detail_id = ?', $id)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     foreach ($records as $record) {
         if (!empty($record['Products']['setup'])) {
             $setup = $record['Products']['setup'];
             // Get the parameters set in the order details (service)
             $params = json_decode($record['parameters'], true);
             if (is_array($params)) {
                 // Get the list of all the domains
                 $domains = OrdersItemsDomains::get_domains($record['detail_id']);
                 // We have to get the first domain
                 if (!empty($domains[0]['domain'])) {
                     $params['domain'] = $domains[0]['domain'];
                     // Get all the var {string} in the xml setup
                     preg_match_all('/{([^}]+)}/Ui', $setup, $matches);
                     foreach ($matches[1] as $parameter) {
                         $setup = str_replace("{" . $parameter . "}", $params[$parameter], $setup);
                     }
                 }
             }
         }
     }
     $xml = simplexml_load_string($setup);
     $arrSetup = Shineisp_Commons_Utilities::simpleXMLToArray($xml);
     return $arrSetup;
 }