Ejemplo n.º 1
0
 /**
  * pgmCall
  *
  * @param string $pgmName Name of program to call, without library
  * @param string $lib Library of program. Leave blank to use library list or current library
  * @param null $inputParam An array of ProgramParameter objects OR XML representing params, to be sent as-is.
  * @param null $returnParam ReturnValue Array of one parameter that's the return value parameter
  * @param null $options Array of other options. The most popular is 'func' indicating the name of a subprocedure or function.
  * @return array|bool
  */
 public function pgmCall($pgmName, $lib, $inputParam = NULL, $returnParam = NULL, $options = NULL)
 {
     $this->cpfErr = '';
     $this->error = '';
     $this->joblog = '';
     $function = NULL;
     ProgramParameter::initializeFallbackVarName();
     // If only one 'return' param, turn it into an array for later processing.
     if ($returnParam instanceof ProgramParameter) {
         $returnParam = array($returnParam);
     }
     $this->XMLWrapper = new XMLWrapper(array('encoding' => $this->getOption('encoding')), $this);
     // $optional handles special requests such as 'license'
     $disconnect = strcmp($pgmName, "OFF") === 0 ? true : false;
     $optional = strcmp($pgmName, "NONE") === 0 ? true : false;
     $outputParamArray = false;
     if (isset($options['func'])) {
         $function = $options['func'];
     }
     if ($disconnect || $optional) {
         $inputXml = $this->XMLWrapper->disconnectXMLIn();
     } else {
         $inputXml = $this->XMLWrapper->buildXmlIn($inputParam, $returnParam, $pgmName, $lib, $function);
     }
     // send XML to XMLSERVICE
     $outputXml = $this->sendXml($inputXml, $disconnect);
     if ($outputXml != '') {
         $outputParamArray = $this->XMLWrapper->getParamsFromXml($outputXml);
         // didn't get expected return, search logs to find out why
         if (!is_array($outputParamArray)) {
             // No real data. Look for errors. Retrieve details from joblog.
             $this->joblog = $this->XMLWrapper->getLastJoblog();
             // standard list of programs that provide CPF codes in joblog
             $programsToLookFor = array($pgmName, '< lveContext', '#mnrnrl', 'QRNXIE', '< allProgram');
             if (isset($this->_cpfMapping[$pgmName])) {
                 // list of other programs not called directly that might generate CPF codes in joblog.
                 $programsToLookFor = array_merge($programsToLookFor, $this->_cpfMapping[$pgmName]);
             }
             // put values in $this->cpfErr and $this->error
             $this->extractErrorFromJoblog($programsToLookFor);
         }
     }
     unset($this->XMLWrapper);
     // output array includes in/out parameters and return parameters.
     return $outputParamArray;
 }