Exemplo n.º 1
0
 /**
  * Main constructor
  * @see WsdlToPhpModel::__construct()
  * @uses WsdlToPhpService::setFunctions()
  * @param string $_name the function name
  * @return WsdlToPhpService
  */
 public function __construct($_name)
 {
     parent::__construct($_name);
 }
Exemplo n.º 2
0
 /**
  * Returns the owner model object, meaning a WsdlToPhpService object
  * @see WsdlToPhpModel::getOwner()
  * @uses WsdlToPhpModel::getOwner()
  * @return WsdlToPhpService
  */
 public function getOwner()
 {
     return parent::getOwner();
 }
Exemplo n.º 3
0
 /**
  * Updates models with model
  * @uses WsdlToPhpModel::getName()
  * @uses WsdlToPhpModel::__toString()
  * @param WsdlToPhpModel $_model a WsdlToPhpModel object
  * @return WsdlToPhpStruct|bool
  */
 protected static function updateModels(WsdlToPhpModel $_model)
 {
     if ($_model->__toString() != 'WsdlToPhpStruct' || !$_model->getName()) {
         return false;
     }
     return self::$models['_' . $_model->getName() . '_'] = $_model;
 }
Exemplo n.º 4
0
 /**
  * Returns the attributes of the struct and potentially from the parent class
  * @uses WsdlToPhpModel::getInheritance()
  * @uses WsdlToPhpModel::getModelByName()
  * @uses WsdlToPhpStruct::getIsStruct()
  * @uses WsdlToPhpStruct::getAttributes()
  * @param bool $_includeInheritanceAttributes include the attributes of parent class, default parent attributes are not included. If true, then the array is an associative array containing and index "attribute" for the WsdlToPhpStructAttribute object and an index "model" for the WsdlToPhpStruct object.
  * @param bool $_requiredFirst places the required attributes first, then the not required in order to have the _contrust method with the required attribute at first
  * @return array
  */
 public function getAttributes($_includeInheritanceAttributes = false, $_requiredFirst = false)
 {
     $attributes = $this->attributes;
     /**
      * Returns the inherited attributes
      */
     if ($_includeInheritanceAttributes) {
         $attributes = array();
         if ($this->getInheritance() != '') {
             $model = WsdlToPhpModel::getModelByName($this->getInheritance());
             while ($model && $model->getIsStruct()) {
                 $modelAttributes = $model->getAttributes();
                 if (count($modelAttributes)) {
                     foreach ($modelAttributes as $attribute) {
                         array_push($attributes, array('attribute' => $attribute, 'model' => $model));
                     }
                 }
                 unset($modelAttributes);
                 $model = WsdlToPhpModel::getModelByName($model->getInheritance());
             }
         }
         $thisAttributes = $this->getAttributes();
         if (count($thisAttributes)) {
             foreach ($thisAttributes as $attribute) {
                 array_push($attributes, array('attribute' => $attribute, 'model' => $this));
             }
         }
         unset($thisAttributes);
     }
     /**
      * Returns the required attributes at first position
      */
     if ($_requiredFirst) {
         $requiredAttributes = array();
         $notRequiredAttributes = array();
         foreach ($attributes as $attribute) {
             $attributeModel = $_includeInheritanceAttributes ? $attribute['attribute'] : $attribute;
             if ($attributeModel->isRequired()) {
                 array_push($requiredAttributes, $attribute);
             } else {
                 array_push($notRequiredAttributes, $attribute);
             }
         }
         $attributes = array();
         foreach ($requiredAttributes as $attribute) {
             array_push($attributes, $attribute);
         }
         foreach ($notRequiredAttributes as $attribute) {
             array_push($attributes, $attribute);
         }
         unset($requiredAttributes, $notRequiredAttributes);
     }
     return $attributes;
 }
Exemplo n.º 5
0
 /**
  * Gets category part
  * @uses WsdlToPhpGenerator::getOptionCategory()
  * @uses WsdlToPhpGenerator::getOptionSubCategory()
  * @uses WsdlToPhpGenerator::getPart()
  * @uses WsdlToPhpGenerator::getOptionGatherMethods()
  * @uses WsdlToPhpModel::getCleanName()
  * @uses WsdlToPhpModel::getContextualPart()
  * @param WsdlToPhpModel $_model the model for which we generate the folder
  * @param string $_optionName category type
  * @return string
  */
 protected function getPart(WsdlToPhpModel $_model, $_optionName)
 {
     $elementType = '';
     $optionValue = 0;
     $string = $_model->getCleanName();
     switch ($_optionName) {
         case self::OPT_CAT_KEY:
             $optionValue = self::getOptionCategory();
             break;
         case self::OPT_SUB_CAT_KEY:
             $optionValue = self::getOptionSubCategory();
             $mainCatPart = $this->getPart($_model, self::OPT_CAT_KEY);
             switch (self::getOptionCategory()) {
                 case self::OPT_CAT_END_NAME:
                     if ($string != $mainCatPart && strlen($mainCatPart) < strlen($string)) {
                         $string = substr($string, 0, strlen($string) - strlen($mainCatPart));
                     } elseif ($string == $mainCatPart) {
                         $string = '';
                     }
                     break;
                 case self::OPT_CAT_START_NAME:
                     if ($string != $mainCatPart && strlen($mainCatPart) < strlen($string)) {
                         $string = substr($string, strlen($mainCatPart));
                     } elseif ($string == $mainCatPart) {
                         $string = '';
                     }
                     break;
                 case self::OPT_CAT_NONE_NAME:
                 case self::OPT_CAT_TYPE:
                 default:
                     $string = '';
                     break;
             }
             break;
         case self::OPT_GATH_METH_KEY:
             $optionValue = self::getOptionGatherMethods();
             break;
     }
     if (!empty($string)) {
         switch ($optionValue) {
             case self::OPT_CAT_END_NAME:
             case self::OPT_SUB_CAT_END_NAME:
             case self::OPT_GATH_METH_END_NAME:
                 /**
                  * Determine category from last word
                  */
                 $parts = preg_split('/[A-Z]/', ucfirst($string));
                 /**
                  * Ex : Error or error
                  */
                 if (count($parts) == 0) {
                     $elementType = $string;
                 } elseif (!empty($parts[count($parts) - 1])) {
                     $elementType = substr($string, strrpos($string, implode('', array_slice($parts, -1))) - 1);
                 } else {
                     $part = '';
                     for ($i = count($parts) - 1; $i >= 0; $i--) {
                         $part = trim($parts[$i]);
                         if (!empty($part)) {
                             break;
                         }
                     }
                     $elementType = substr($string, (count($parts) - 2 - $i + 1) * -1);
                 }
                 break;
             case self::OPT_CAT_START_NAME:
             case self::OPT_SUB_CAT_START_NAME:
             case self::OPT_GATH_METH_START_NAME:
                 /**
                  * Determine category from first word
                  */
                 $parts = preg_split('/[A-Z]/', ucfirst($string));
                 /**
                  * Ex : Error or error
                  */
                 if (count($parts) == 0) {
                     $elementType = $string;
                 } elseif (empty($parts[0]) && !empty($parts[1])) {
                     $elementType = substr($string, 0, strlen($parts[1]) + 1);
                 } else {
                     $part = '';
                     for ($i = 0; $i < count($parts); $i++) {
                         $part = trim($parts[$i]);
                         if (!empty($part)) {
                             break;
                         }
                     }
                     $elementType = substr($string, 0, $i);
                 }
                 break;
             case self::OPT_CAT_TYPE:
                 $elementType = $_model->getContextualPart();
                 break;
             case self::OPT_CAT_NONE_NAME:
             case self::OPT_SUB_CAT_NONE_NAME:
             default:
                 break;
         }
     }
     return $elementType;
 }
Exemplo n.º 6
0
/**
 * Librairies
 */
$localDir = dirname(__FILE__) . '/';
require_once $localDir . 'WsdlToPhpModel.php';
require_once $localDir . 'WsdlToPhpStruct.php';
require_once $localDir . 'WsdlToPhpService.php';
require_once $localDir . 'WsdlToPhpFunction.php';
require_once $localDir . 'WsdlToPhpGenerator.php';
require_once $localDir . 'WsdlToPhpStructValue.php';
require_once $localDir . 'WsdlToPhpStructAttribute.php';
/**
 * Cleaning tests
 */
if (false) {
    echo "\r\n Clean Name for '2And'is-go54  83od+*/you=yèçés_3' is " . WsdlToPhpModel::cleanString("2And'is-go54  83od+*/you=yéçès_3") . " \r\n";
    return;
}
/**
 * OVH SOAP API
 * Lots of structs and operations
 */
if (false) {
    $w = new WsdlToPhpGenerator('http://www.ovh.com/soapi/soapi-dlw-1.54.wsdl');
    WsdlToPhpGenerator::setOptionGenerateAutoloadFile(true);
    WsdlToPhpGenerator::setOptionGenerateWsdlClassFile(true);
    WsdlToPhpGenerator::setOptionResponseAsWsdlObject(true);
    WsdlToPhpGenerator::setOptionGenerateTutorialFile(true);
    WsdlToPhpGenerator::setOptionCategory(WsdlToPhpGenerator::OPT_CAT_START_NAME);
    WsdlToPhpGenerator::setOptionSubCategory(WsdlToPhpGenerator::OPT_SUB_CAT_END_NAME);
    $w->generateClasses('ovh', dirname(__FILE__) . '/samples/ovh/');