* @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('CLI_SCRIPT', true);
require __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '../../../config.php';
$wsdl = 'http://testing.dev/apollo.xml?wsdl';
$outputdir = __DIR__ . '/classes/soap/generated';
// Pull complex types out of wsdl which contain 'html' (apollo api methods).
$wsdlcontents = file_get_contents($wsdl);
if (!$wsdlcontents) {
    die('Failed to load wsdl ' . $wsdl);
}
$wsdlxe = new simpleXMLElement($wsdlcontents);
// Remove doc elements (causing issues with wsdl parser).
$docels = $wsdlxe->xpath('//wsdl:documentation');
$docelsarr = [];
foreach ($docels as $docel) {
    $docelsarr[] = $docel;
}
foreach ($docelsarr as $docel) {
    unset($docel[0]);
}
// Create local wsdl.
$wsdlxe->asXML(__DIR__ . '/wsdl.xml');
$whitelist = ['Html', 'Apollo', 'UrlResponse', 'ServerConfiguration', 'Success'];
$htmlels = $wsdlxe->xpath('//xs:complexType | //xs:element');
$soapclasses = ['SASDefaultAdapter'];
foreach ($htmlels as $htmlel) {
    $name = '' . $htmlel->attributes()['name'];
    foreach ($whitelist as $witem) {
Exemplo n.º 2
0
 /**
  * Return the contents of MARC data fields as an array
  *
  * @param simpleXMLElement $xml        MARC Record
  * @param string           $fieldspecs Fields and subfields (e.g. '100a:700a')
  * @param string           $glue       Delimiter used between subfields
  *
  * @return array
  */
 protected function getMultipleValues($xml, $fieldspecs, $glue = '')
 {
     $values = [];
     foreach (explode(':', $fieldspecs) as $fieldspec) {
         $field = substr($fieldspec, 0, 3);
         $subfields = substr($fieldspec, 3);
         $xpath = "./m:datafield[@tag='{$field}']";
         $res = $xml->xpath($xpath);
         foreach ($res as $datafield) {
             $strings = [];
             foreach ($datafield->subfield as $subfield) {
                 if (strstr($subfields, (string) $subfield['code'])) {
                     $strings[] .= (string) $subfield;
                 }
             }
             if ($strings) {
                 $values[] = implode($glue, $strings);
             }
         }
     }
     return $values;
 }
Exemplo n.º 3
0
 /**
  * @param simpleXMLElement $xml_obj
  */
 private function _processXML($xml_obj)
 {
     $xml = $xml_obj->xpath('/datasets');
     $datasets = $xml;
     //process each layout
     foreach ($datasets as $dataset) {
         /**
          * @var SimpleXMLElement $dataset
          */
         $dataset = $dataset->dataset;
         /* Determine an action tag in all parent elements. 
          * Action can be insert, update and delete		       
          *   ->>> action = insert
          *		Mean that we will try create new dataset with column definitions and insert rows in it  
          *  ->>> action = update (default)
          *		Before loading the dataset, determine if same dataset exists with same name and key combination.
          *		If does exists, write new over existing
          *  ->>> action = delete
          *		Delete all that contains in dataset (values, definitions, properties and dataset)					
          *		NOTE: Parent level delete action is cascaded to all children elements
          */
         if (!$dataset->action) {
             $dataset->action = 'update';
         }
         if (in_array($dataset->action, array("update", "delete"))) {
             $this->__construct($dataset->dataset_name, $dataset->dataset_key);
             $this->dropDataset();
             if ($dataset->action == "delete") {
                 continue;
             }
         }
         if (in_array($dataset->action, array("insert", "update"))) {
             if ($dataset->dataset_name) {
                 $this->__construct($dataset->dataset_name, $dataset->dataset_key);
                 $this->createDataset($dataset->dataset_name, $dataset->dataset_key);
             }
         }
         // check creating
         if (!$this->dataset_id) {
             continue;
         }
         // set dataset definition if needed
         if ($dataset->dataset_definition && $dataset->dataset_definition->column_definition) {
             $definitions = array();
             $i = 0;
             foreach ($dataset->dataset_definition->column_definition as $column_definition) {
                 $definitions[$i]['name'] = (string) $column_definition->column_name;
                 $definitions[$i]['type'] = (string) $column_definition->column_type;
                 if ((int) $column_definition->column_sort_order) {
                     $definitions[$i]['sort_order'] = (int) $column_definition->column_sort_order;
                 }
                 $i++;
             }
             $this->defineColumns($definitions);
         }
         // set dataset properties if needed
         if ($dataset->dataset_properties && $dataset->dataset_properties->dataset_property) {
             $properties = array();
             foreach ($dataset->dataset_properties->dataset_property as $property) {
                 $properties[(string) $property->dataset_property_name] = (string) $property->dataset_property_value;
             }
             $this->setDatasetProperties($properties);
         }
         // set column properties if needed
         if ($dataset->column_properties && $dataset->column_properties->column_property) {
             $properties = array();
             foreach ($dataset->column_properties->column_property as $property) {
                 $properties[(string) $property->column_property_name] = (string) $property->column_property_value;
                 $this->setColumnProperties((string) $property->column_name, $properties);
             }
         }
         // operate with dataset rows
         if ($dataset->dataset_rows && $dataset->dataset_rows->dataset_row) {
             $row_values = array();
             foreach ($dataset->dataset_rows->dataset_row as $row) {
                 if ($row->cell) {
                     foreach ($row->cell as $cell) {
                         $row_values[][(string) $cell->column_name] = (string) $cell->value;
                     }
                 }
             }
             $this->addRows($row_values);
         }
     }
     // end of loop
 }