public static function buildFromPathfile($pathfile, \collection $collection, Application $app, $originalName = null)
    {
        try {
            $media = $app->getMediaFromUri($pathfile);
        } catch (FileNotFoundException $e) {
            throw new \InvalidArgumentException(sprintf('Unable to build media file from non existant %s', $pathfile));
        }

        return new File($app, $media, $collection, $originalName);
    }
public static function buildFromPathfile($pathfile, \collection $collection, Application $app, $originalName = null)
    {
        try {
            $media = $app->getMediaFromUri($pathfile);
        } catch (FileNotFoundException $e) {
            throw new \InvalidArgumentException(sprintf('Unable to build media file from non existant %s', $pathfile));
        }

        return new File($app, $media, $collection, $originalName);
    }
public static function buildFromPathfile ( $ pathfile , \ collection $ collection , Application $ app , $ originalName = null ) { try { $ media = $ app -> getMediaFromUri ( $ pathfile ) ; } catch ( FileNotFoundException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Unable to build media file from non existant %s' , $ pathfile ) ) ; } return new File ( $ app , $ media , $ collection , $ originalName ) ; }
Build the File package object

@param  string                    $pathfile     The path to the file
@param  \collection               $collection   The destination collection
@param  Application               $app          An application
@param  string                    $originalName An optionnal original name (if
different from the $pathfile filename)
@throws \InvalidArgumentException

@return File
Build the File package object