concrete/src/File/Set/Set.php
public function addFileToSet($f_id)
    {
        $app = Application::getFacadeApplication();
        if (is_object($f_id)) {
            $f = $f_id;
            if ($f instanceof FileEntity) {
                $file = $f;
                $fileVersion = $file->getApprovedVersion();
            } else {
                $fileVersion = $f;
                $file = $fileVersion->getFile();
            }
            $f_id = (int) $file->getFileID();
        } else {
            $f_id = (int) $f_id;
            $em = $app->make(EntityManagerInterface::class);
            $file = $em->find(FileEntity::class, $f_id);
            $fileVersion = $file->getApprovedVersion();
        }
        if ($file === null) {
            $result = null;
        } else {
            $file_set_file = File::createAndGetFile($f_id, $this->fsID);
            $fe = new \Concrete\Core\File\Event\FileSetFile($file_set_file);
            $director = $app->make(EventDispatcherInterface::class);
            $director->dispatch('on_file_added_to_set', $fe);
            if ($fileVersion !== null && $this->shouldRefreshFileThumbnails('add')) {
                $fileVersion->refreshThumbnails(false);
            }
            $result = $file_set_file;
        }

        return $result;
    }
public function addFileToSet($f_id)
    {
        $app = Application::getFacadeApplication();
        if (is_object($f_id)) {
            $f = $f_id;
            if ($f instanceof FileEntity) {
                $file = $f;
                $fileVersion = $file->getApprovedVersion();
            } else {
                $fileVersion = $f;
                $file = $fileVersion->getFile();
            }
            $f_id = (int) $file->getFileID();
        } else {
            $f_id = (int) $f_id;
            $em = $app->make(EntityManagerInterface::class);
            $file = $em->find(FileEntity::class, $f_id);
            $fileVersion = $file->getApprovedVersion();
        }
        if ($file === null) {
            $result = null;
        } else {
            $file_set_file = File::createAndGetFile($f_id, $this->fsID);
            $fe = new \Concrete\Core\File\Event\FileSetFile($file_set_file);
            $director = $app->make(EventDispatcherInterface::class);
            $director->dispatch('on_file_added_to_set', $fe);
            if ($fileVersion !== null && $this->shouldRefreshFileThumbnails('add')) {
                $fileVersion->refreshThumbnails(false);
            }
            $result = $file_set_file;
        }

        return $result;
    }
public function addFileToSet ( $ f_id ) { $ app = Application :: getFacadeApplication ( ) ; if ( is_object ( $ f_id ) ) { $ f = $ f_id ; if ( $ f instanceof FileEntity ) { $ file = $ f ; $ fileVersion = $ file -> getApprovedVersion ( ) ; } else { $ fileVersion = $ f ; $ file = $ fileVersion -> getFile ( ) ; } $ f_id = ( int ) $ file -> getFileID ( ) ; } else { $ f_id = ( int ) $ f_id ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ file = $ em -> find ( FileEntity :: class , $ f_id ) ; $ fileVersion = $ file -> getApprovedVersion ( ) ; } if ( $ file === null ) { $ result = null ; } else { $ file_set_file = File :: createAndGetFile ( $ f_id , $ this -> fsID ) ; $ fe = new \ Concrete \ Core \ File \ Event \ FileSetFile ( $ file_set_file ) ; $ director = $ app -> make ( EventDispatcherInterface :: class ) ; $ director -> dispatch ( 'on_file_added_to_set' , $ fe ) ; if ( $ fileVersion !== null && $ this -> shouldRefreshFileThumbnails ( 'add' ) ) { $ fileVersion -> refreshThumbnails ( false ) ; } $ result = $ file_set_file ; } return $ result ; }
Adds the file to the set.

@param int|FileEntity|FileVersionEntity $f_id

@return \Concrete\Core\File\Set\File|null returns NULL if the operation failed (for instance because $f_id is invalid), a \Concrete\Core\File\Set\File instance otherwise
Adds the file to the set .