Example #1
0
 /**
  * Check Data integrity
  *
  * @return $this Current object
  */
 public function check()
 {
     // run save check method
     if (!$this->record->resource->check()) {
         array_push($this->record->errors, $this->record->resource->getError());
     }
     // check custom field if we have that on
     if ($this->_options['requiredfields'] && isset($this->record->type->id)) {
         $resourcesElements = new \Components\Resources\Models\Elements((array) $this->record->custom, $this->record->type->customFields);
         foreach ($resourcesElements->getSchema()->fields as $field) {
             $value = $resourcesElements->get($field->label);
             if ($field->required && (!isset($value) || $value == '')) {
                 array_push($this->record->errors, Lang::txt('COM_RESOURCES_IMPORT_RECORD_MODEL_MISSING_REQUIREDCUSTOMFIELDS', $field->label));
             }
         }
     }
     // chainability
     return $this;
 }