PKPSubmissionFileDAO::_castToGenre PHP Method

_castToGenre() private method

NB: In the case of a downcast this means that not all data in the object will be saved to the database. It is the UI's responsibility to inform users about potential loss of data if they change to a genre that permits less meta-data than the prior genre!
private _castToGenre ( $submissionFile ) : SubmissionFile
$submissionFile SubmissionFile
return SubmissionFile The same file in a compatible implementation.
    private function _castToGenre($submissionFile)
    {
        // Find the required target implementation.
        $targetImplementation = strtolower_codesafe($this->_getFileImplementationForGenreId($submissionFile->getGenreId()));
        // If the current implementation of the updated object
        // is the same as the target implementation, skip cast.
        if (is_a($submissionFile, $targetImplementation)) {
            return $submissionFile;
        }
        // The updated file has to be upcast by manually
        // instantiating the target object and copying data
        // to the target.
        $targetDaoDelegate = $this->_getDaoDelegate($targetImplementation);
        $targetFile = $targetDaoDelegate->newDataObject();
        $targetFile = $submissionFile->upcastTo($targetFile);
        return $targetFile;
    }