public function setFileContentFromFilesystem($filename)
    {
        if (!$filename) {
            throw new RuntimeException('The filename may not be empty');
        }
        if (!is_readable($filename)) {
            throw new RuntimeException(sprintf('File "%s" not found or not readable', $filename));
        }
        $this->getContent();
        $stream = fopen($filename, 'rb');
        if (!$stream) {
            throw new RuntimeException(sprintf('Failed to open file "%s"', $filename));
        }

        $this->content->setData($stream);
        $this->content->setLastModified(new \DateTime('@'.filemtime($filename)));

        $finfo = new \finfo();
        $this->content->setMimeType($finfo->file($filename, FILEINFO_MIME_TYPE));
        $this->content->setEncoding($finfo->file($filename, FILEINFO_MIME_ENCODING));

        return $this;
    }
public function setFileContentFromFilesystem($filename)
    {
        if (!$filename) {
            throw new RuntimeException('The filename may not be empty');
        }
        if (!is_readable($filename)) {
            throw new RuntimeException(sprintf('File "%s" not found or not readable', $filename));
        }
        $this->getContent();
        $stream = fopen($filename, 'rb');
        if (!$stream) {
            throw new RuntimeException(sprintf('Failed to open file "%s"', $filename));
        }

        $this->content->setData($stream);
        $this->content->setLastModified(new \DateTime('@'.filemtime($filename)));

        $finfo = new \finfo();
        $this->content->setMimeType($finfo->file($filename, FILEINFO_MIME_TYPE));
        $this->content->setEncoding($finfo->file($filename, FILEINFO_MIME_ENCODING));

        return $this;
    }
public function setFileContentFromFilesystem ( $ filename ) { if ( ! $ filename ) { throw new RuntimeException ( 'The filename may not be empty' ) ; } if ( ! is_readable ( $ filename ) ) { throw new RuntimeException ( sprintf ( 'File "%s" not found or not readable' , $ filename ) ) ; } $ this -> getContent ( ) ; $ stream = fopen ( $ filename , 'rb' ) ; if ( ! $ stream ) { throw new RuntimeException ( sprintf ( 'Failed to open file "%s"' , $ filename ) ) ; } $ this -> content -> setData ( $ stream ) ; $ this -> content -> setLastModified ( new \ DateTime ( '@' . filemtime ( $ filename ) ) ) ; $ finfo = new \ finfo ( ) ; $ this -> content -> setMimeType ( $ finfo -> file ( $ filename , FILEINFO_MIME_TYPE ) ) ; $ this -> content -> setEncoding ( $ finfo -> file ( $ filename , FILEINFO_MIME_ENCODING ) ) ; return $ this ; }
Set the content for this file from the given filename.
Calls file_get_contents with the given filename.

@param string $filename name of the file which contents should be used

@throws RuntimeException If the filename does not point to a file that can be read.

@return $this
Set the content for this file from the given filename . Calls file_get_contents with the given filename .