Example #1
0
 /**
  * Returns a Field object that describes the specified field.
  *
  * @param string $fieldName Name of field.
  *
  * @return Field|FileMakerException Field object, if successful.
  * @throws FileMakerException
  */
 public function getField($fieldName)
 {
     if (isset($this->fields[$fieldName])) {
         return $this->fields[$fieldName];
     }
     $error = new FileMakerException($this->fm, 'Field ' . $fieldName . ' Not Found in Layout ' . $this->layout->getName());
     if ($this->fm->getProperty('errorHandling') === 'default') {
         return $error;
     }
     throw $error;
 }
Example #2
0
 /**
  *
  * @return boolean|FileMakerException TRUE on success
  * @throws FileMakerException
  */
 private function _commitEditChild()
 {
     $modifiedFields = [];
     foreach ($this->fields as $fieldName => $repetitions) {
         foreach ($repetitions as $repetition => $value) {
             if (!empty($this->_modifiedFields[$fieldName][$repetition])) {
                 $modifiedFields[$fieldName . '.' . $this->recordId][$repetition] = $value;
             }
         }
     }
     $editCommand = $this->fm->newEditCommand($this->parent->layout->getName(), $this->parent->getRecordId(), $modifiedFields);
     $result = $editCommand->execute();
     if (FileMaker::isError($result)) {
         return $result;
     }
     $records = $result->getRecords();
     $firstRecord = $records[0];
     $relatedSet = $firstRecord->getRelatedSet($this->layout->getName());
     if (FileMaker::isError($relatedSet)) {
         return $relatedSet;
     }
     foreach ($relatedSet as $record) {
         if ($record->getRecordId() == $this->recordId) {
             return $this->_updateFrom($record);
             break;
         }
     }
     $error = new FileMakerException($this->fm, 'Failed to find the updated child in the response.');
     if ($this->fm->getProperty('errorHandling') === 'default') {
         return $error;
     }
     throw $error;
 }
Example #3
0
 /**
  * Add extended infos to a Layout object
  *
  * @param Layout $layout
  * @return FileMakerException
  * @throws FileMakerException
  */
 public function setExtendedInfo(Layout $layout)
 {
     if (!$this->_isParsed) {
         $error = new FileMakerException($this->_fm, 'Attempt to set extended information before parsing data.');
         if ($this->_fm->getProperty('errorHandling') === 'default') {
             return $error;
         }
         throw $error;
     }
     $layout->valueLists = $this->_valueLists;
     $layout->valueListTwoFields = $this->_valueListTwoFields;
     foreach ($this->_fields as $fieldName => $fieldInfos) {
         try {
             $field = $layout->getField($fieldName);
             if (!FileMaker::isError($field)) {
                 $field->styleType = $fieldInfos['styleType'];
                 $field->valueList = $fieldInfos['valueList'] ? $fieldInfos['valueList'] : null;
             }
         } catch (\Exception $e) {
             //Field may be missing when it is stored in a portal, ommit error
         }
     }
 }
Example #4
0
 /**
  * Returns the names of related tables for all portals present in records
  * in this result set.
  *
  * @return array List of related table names as strings.
  */
 public function getRelatedSets()
 {
     return $this->layout->listRelatedSets();
 }