Antidot PHP API  version 0.16.0
##PHP API to simplify integration of Antidot components
 All Classes Files Functions Variables Groups Pages
Public Member Functions | List of all members
AfsDocument Class Reference

Represent a document. More...

Public Member Functions

 __construct ($data=null, $mime_type=null)
 Construct new document instance.
 set_content ($data, $mime_type=null)
 Define document content and mime-type.
 set_content_from_file ($filename, $mime_type=null)
 Define document content for existing file and mime-type.
 is_valid ()
 Check whether document is valid.
 get_filename ()
 Retrieve document filename.
 get_mime_type ()
 Retrieve the mime-type of the document.

Detailed Description

Represent a document.

This document can be sent to Antidot component such as PaF through Antidot Back Office APIs.

Constructor & Destructor Documentation

__construct (   $data = null,
  $mime_type = null 
)

Construct new document instance.

Newly created document can be empty and filled later on, or filled with appropriate content.

Remarks
It is hardly recommended to set appropriate mime_type value. Autodetection does not perform well for JSON documents, XML documents whithout header and probably other types of documents.
Parameters
$data[in] string corresponding to the content of the created document (default: null, document is not initialized).
$mime_type[in] mime-type of the document (default: null). If not set mime-type will be automatically detected.
Exceptions
InvalidArgumentExceptionwhen data is not a string.

Member Function Documentation

get_filename ( )

Retrieve document filename.

When the document is initialized with string data, temporary file is created. It is automatically removed at the end of the script.

Returns
document filename.
get_mime_type ( )

Retrieve the mime-type of the document.

Returns
mime-type.
is_valid ( )

Check whether document is valid.

Returns
true when the document is valid, false otherwise.
set_content (   $data,
  $mime_type = null 
)

Define document content and mime-type.

Parameters
$data[in] new document content.
$mime_type[in] mime-type of the document (default: null). If not set mime-type will be automatically detected.
Exceptions
InvalidArgumentExceptionwhen data is not a string.
set_content_from_file (   $filename,
  $mime_type = null 
)

Define document content for existing file and mime-type.

Parameters
$filename[in] Name of the file to use as document.
$mime_type[in] mime-type of the document (default: null). If not set mime-type will be automatically detected.
Exceptions
RuntimeExceptionwhen provided filename does not exist.