public static function getPathFromContent(ElementFile $content, $folder_size = 3)
    {
        if (null === $content->getUid()
                || null === $content->originalname) {
            throw new InvalidArgumentException('Enable to compute path, the provided element file is not yet initialized');
        }

        $folder = '';
        $filename = $content->getUid();
        if (null !== $draft = $content->getDraft()) {
            $filename = $draft->getUid();
        }

        if (0 < $folder_size && strlen($filename) > $folder_size) {
            $folder = substr($filename, 0, $folder_size).'/';
            $filename = substr($filename, $folder_size);
        }

        $extension = File::getExtension($content->originalname, true);

        return $folder.$filename.$extension;
    }
public static function getPathFromContent(ElementFile $content, $folder_size = 3)
    {
        if (null === $content->getUid()
                || null === $content->originalname) {
            throw new InvalidArgumentException('Enable to compute path, the provided element file is not yet initialized');
        }

        $folder = '';
        $filename = $content->getUid();
        if (null !== $draft = $content->getDraft()) {
            $filename = $draft->getUid();
        }

        if (0 < $folder_size && strlen($filename) > $folder_size) {
            $folder = substr($filename, 0, $folder_size).'/';
            $filename = substr($filename, $folder_size);
        }

        $extension = File::getExtension($content->originalname, true);

        return $folder.$filename.$extension;
    }
public static function getPathFromContent ( ElementFile $ content , $ folder_size = 3 ) { if ( null === $ content -> getUid ( ) || null === $ content -> originalname ) { throw new InvalidArgumentException ( 'Enable to compute path, the provided element file is not yet initialized' ) ; } $ folder = '' ; $ filename = $ content -> getUid ( ) ; if ( null !== $ draft = $ content -> getDraft ( ) ) { $ filename = $ draft -> getUid ( ) ; } if ( 0 < $ folder_size && strlen ( $ filename ) > $ folder_size ) { $ folder = substr ( $ filename , 0 , $ folder_size ) . '/' ; $ filename = substr ( $ filename , $ folder_size ) ; } $ extension = File :: getExtension ( $ content -> originalname , true ) ; return $ folder . $ filename . $ extension ; }
Returns the computed storage filename of an element file.

@param \BackBee\ClassContent\Element\File $content
@param int                                $folder_size Optional, size in characters of the storing folder

@return string

@throws \BackBee\Exception\InvalidArgumentException Occurs if the provided element file is empty
Returns the computed storage filename of an element file .