/** * resource i5_userspace_get(resource user space, array params) * Retrieve user space data. * * @param $userspace User Space resource opened by i5_userspace_prepare * @param $params output params with php variable names. * @param int $offset Offset from the beginning of the user space, of the data to get. Not documented in Zend documentation. * @return bool */ function i5_userspace_get($userspace, $params, $offset = 1) { // check parameters if (!isset($userspace)) { i5ErrorActivity(I5_ERR_PHP_ELEMENT_MISSING, I5_CAT_PHP, 'Missing user space description', 'Missing user space description'); return false; } if (!is_object($userspace)) { i5ErrorActivity(I5_ERR_PHP_TYPEPARAM, I5_CAT_PHP, 'User space description must be a description resource', 'User space description must be a description resource'); return false; } if (!isset($params)) { i5ErrorActivity(I5_ERR_PHP_ELEMENT_MISSING, I5_CAT_PHP, 'Params are required', 'Params are required'); return false; } if (!is_array($params)) { i5ErrorActivity(I5_ERR_PHP_TYPEPARAM, I5_CAT_PHP, 'Params must be an array', 'Params must be an array'); return false; } $outputParams = $params; $conn = $userspace->getConnection(); // get lib and obj $usInfo = $userspace->getObjInfo(); // format the user space name and library into 20 char format $usObj = new UserSpace(); $usObj->setUSName($usInfo['obj'], $usInfo['lib']); // @todo be OK when no values are passed. // convert from old to new param format, inserting input values, when later call generateNewToolkitParams. // It won't affect the "new toolkit" style params that we specify directly. $userspace->setIsReceiverOnly(true); // receiver only, so it will use default/blank input values. $labelForSizeOfInputData = 'dssize'; $receiverVarName = 'receiverdata'; $oldDescription = $userspace->getOriginalDescription(); // wrap data var in a ds so we can set size and get the result easily // and also to wrap "loose" params passed in $wrappedOldToolkitParams = array(array('DSName' => $receiverVarName, 'DSParm' => $oldDescription)); // use null because we're creating a receiver with no data yet. $newInputParams = $userspace->generateNewToolkitParams(null, $wrappedOldToolkitParams); if (!$newInputParams) { // some problem converting return false; } // only want one param, the data queue description $receiveStructure = $newInputParams[0]; $toolkitParams = array(); $toolkitParams[] = Toolkit::AddParameterChar('in', 20, "User space name and library", 'userspacename', $usObj->getUSFullName()); $toolkitParams[] = Toolkit::AddParameterInt32('in', "From position", 'position_from', $offset); $toolkitParams[] = Toolkit::AddParameterSize("Length of data", 'dataLen', $labelForSizeOfInputData); // update "label for size of structure" in structure, so XMLSERVICE can get its size $receiveStructure->setParamLabelLen($labelForSizeOfInputData); $toolkitParams[] = $receiveStructure; //$receiveDs[] = $toolkitParams[] = Toolkit::AddErrorDataStructZeroBytes(); // read from the user space $retPgmArr = $conn->PgmCall('QUSRTVUS', 'QSYS', $toolkitParams); // check for any errors //if( $conn->verify_CPFError($retPgmArr , "User space get failed.")) { if ($conn->getErrorCode()) { i5CpfError($conn->getErrorCode(), $conn->getErrorMsg()); return false; } else { // extricate the data from the receiver variable ds wrapper $outputArray = $retPgmArr['io_param'][$receiverVarName]; // export vars then return true if ($outputArray) { //$exportedThem = exportPgmOutputVars($outputParams, $outputArray); $exportedThem = $userspace->getConnection()->setOutputVarsToExport($outputParams, $outputArray); if (!$exportedThem) { return false; } } noError(); return true; } }
public function testCanAddParameterSize() { $size = $this->toolkit->AddParameterSize('test comment', 'varName', 3); $this->assertTrue($size instanceof SizeParam); }