protected function createDataObject($fileID)
    {
        $recordClass = $this->component->getRecordClassName($this->gridField);
        $record = $recordClass::create();
        $record->write();

        $record->extend('onBulkUpload', $this->gridField);

        $fileRelationName = $this->component->getFileRelationName($this->gridField);
        $record->{"{$fileRelationName}ID"} = $fileID;
        $record->write(); //HasManyList call write on record but not ManyManyList, so we call it here again
        
        $this->gridField->list->add($record);

        if ($this->component->getAutoPublishDataObject() && $record->hasExtension('Versioned'))
        {
            $record->publishRecursive();
        }

        return $record;
    }
protected function createDataObject($fileID)
    {
        $recordClass = $this->component->getRecordClassName($this->gridField);
        $record = $recordClass::create();
        $record->write();

        $record->extend('onBulkUpload', $this->gridField);

        $fileRelationName = $this->component->getFileRelationName($this->gridField);
        $record->{"{$fileRelationName}ID"} = $fileID;
        $record->write(); //HasManyList call write on record but not ManyManyList, so we call it here again
        
        $this->gridField->list->add($record);

        if ($this->component->getAutoPublishDataObject() && $record->hasExtension('Versioned'))
        {
            $record->publishRecursive();
        }

        return $record;
    }
protected function createDataObject ( $ fileID ) { $ recordClass = $ this -> component -> getRecordClassName ( $ this -> gridField ) ; $ record = $ recordClass :: create ( ) ; $ record -> write ( ) ; $ record -> extend ( 'onBulkUpload' , $ this -> gridField ) ; $ fileRelationName = $ this -> component -> getFileRelationName ( $ this -> gridField ) ; $ record -> { "{$fileRelationName}ID" } = $ fileID ; $ record -> write ( ) ; //HasManyList call write on record but not ManyManyList, so we call it here again $ this -> gridField -> list -> add ( $ record ) ; if ( $ this -> component -> getAutoPublishDataObject ( ) && $ record -> hasExtension ( 'Versioned' ) ) { $ record -> publishRecursive ( ) ; } return $ record ; }
Creates a new DataObject
Add file ID to the Dataobject
Add DataObject to Gridfield list
Publish DataObject if enabled

@param integer     $fileID The newly uploaded/attached file ID

@return  DataObject The new DataObject
Creates a new DataObject Add file ID to the Dataobject Add DataObject to Gridfield list Publish DataObject if enabled