Core/ContentWriter.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
Package
Default  

\ContentWriter

Package: Default
Writes temporary file
Author
amatiushkin  

Properties

>VPropertyprivate\type $bytes = null
Number of bytes in content
Default valuenullDetails
Type
\type
>VPropertyprivatemixed $content = null
Contains content to write
Default valuenullDetails
Type
mixed
>VPropertyprivate\type $handler = null
Contains reference to resource (if applicable)
Default valuenullDetails
Type
\type
>VPropertyprivatestring $prefix = null
Prefix which will be added at the beginning of a filename.
Default valuenullDetails
Type
string
See
for details  
>VPropertyprivatestring $tempPath = null
Full path including filename for created temporary file
Default valuenullDetails
Type
string

Methods

methodpublic__construct( $content = NULL) : void

Parameters
NameTypeDescription
$content
methodprivatecreateTempFile() : string

Creates temporary file in system temporary folder.

It returns path to the file
Returns
TypeDescription
stringpath
methodprivategenerateFileName(\type $name) : \type

Creates filename based on name and prefix.

It generates uniqid-like string if name is ommited
Parameters
NameTypeDescription
$name\type
Returns
TypeDescription
\type
methodpublicgetBytes() : \type

Returns number of bytes, which were written

Returns
TypeDescription
\type
methodpublicgetContent() : mixed

Returns content

Returns
TypeDescription
mixed(string or binary)
methodpublicgetHandler() : resource

Returns file handler to temporary file It is the same kind as ones, which are returned by @see fopen()

Returns
TypeDescription
resource
methodprivategetPathFromHandler() : \type

Returns actual path from actual file handler

Returns
TypeDescription
\type
methodpublicgetPrefix() : string

Returns prefix

Returns
TypeDescription
string
methodpublicgetTempPath() : string

Returns path to temporary file

Returns
TypeDescription
string
methodprotectedgetUniqId() : string

Returns unique filename with prefix (if applicable) note: This method is not intented to generate unpredictable strings, even with very low likelihood it may happen with garbaged tmp folder.

Suggestion is to clean up php temp folder (which is usually sys temp folder).
Returns
TypeDescription
string
methodpublicisHandler() : boolean

Returns true if this writer instance refers to file by stream reference

Returns
TypeDescription
boolean
methodpublicresetContent() : void

Deletes content, however everything else remains available This method is intented to use for better memory management

methodpublicsaveAsHandler() : void

Writes content into temporary file and returns open handler to it.

The temporary file is removed when closed (e.g. by calling fclose()) or there are no more references (e.g. variables) or with script termination.
Throws
ExceptionDescription
\SdkException
methodpublicsaveFile(\type $dir, \type $name = null) : void

Moves file from temp location to specified folder and name

Parameters
NameTypeDescription
$dir\type
$name\type

(option) if not speicifed it will be moved with temp name

Throws
ExceptionDescription
\SdkException
methodpublicsaveTemp() : boolean

Writes content into temporary file. It always creates new temp file.

Use getTempPath() to retrieve actual path. This method doesn't delete the file after script termination.
Returns
TypeDescription
boolean
Throws
ExceptionDescription
\SdkException
methodpublicsetPrefix(string $prefix) : void

Set prefix for a temporary filename.

It is used only by saveTemp()
Parameters
NameTypeDescription
$prefixstring
Documentation was generated by phpDocumentor 2.8.5.