NonMimePart extends MessagePart
Represents part of a non-mime message. The part could either be a plain text part or a uuencoded attachment and could be extended for other pre-mime message encoding types.
This allows clients to handle all messages as mime messages by providing a Content-Type header. NonMimePart returns text/plain.
Tags
Table of Contents
- $charsetOverride : string
- $contentStream : StreamInterface
- $ignoreTransferEncoding : bool
- $parent : ParentPart
- $partStreamFilterManager : PartStreamFilterManager
- $stream : StreamInterface
- $streamFactory : StreamFactory
- __construct() : mixed
- Constructor
- __destruct() : mixed
- Overridden to close streams.
- __toString() : string
- Returns the message/part as a string.
- attachContentStream() : mixed
- Attaches the stream or resource handle for the part's content. The stream is closed when another stream is attached, or the MimePart is destroyed.
- detachContentStream() : mixed
- Detaches and closes the content stream.
- getCharset() : string
- Returns ISO-8859-1
- getContent() : string
- Shortcut to reading stream content and assigning it to a string. Returns null if the part doesn't have a content stream.
- getContentDisposition() : string
- Returns 'inline'.
- getContentResourceHandle() : resource
- Returns a new resource stream handle for the part's content or null if the part doesn't have a content section.
- getContentStream() : StreamInterface
- Returns the StreamInterface for the part's content or null if the part doesn't have a content section.
- getContentTransferEncoding() : string
- Returns '7bit'.
- getContentType() : string
- Returns text/plain
- getFilename() : string
- Returns a filename for the part if one is defined, or null otherwise.
- getParent() : MimePart
- Returns this part's parent.
- getResourceHandle() : resource
- Rewrite me
- getStream() : StreamInterface
- Write me
- hasContent() : bool
- Returns true if there's a content stream associated with the part.
- isMime() : bool
- Returns false.
- isTextPart() : bool
- Returns true.
- markAsChanged() : mixed
- Marks the part as changed, forcing the part to be rewritten when saved.
- save() : mixed
- Saves the message/part as to the passed resource handle.
- setCharsetOverride() : mixed
- Overrides the default character set used for reading content from content streams in cases where a user knows the source charset is not what is specified.
- setContent() : mixed
- Sets the content of the part to the passed resource.
- onChange() : mixed
- Called when operations change the content of the MessagePart.
Properties
$charsetOverride
protected
string
$charsetOverride
$contentStream
protected
StreamInterface
$contentStream
$ignoreTransferEncoding
protected
bool
$ignoreTransferEncoding
$parent
protected
ParentPart
$parent
$partStreamFilterManager
protected
PartStreamFilterManager
$partStreamFilterManager
$stream
protected
StreamInterface
$stream
$streamFactory
protected
StreamFactory
$streamFactory
Methods
__construct()
Constructor
public
__construct(PartStreamFilterManager $partStreamFilterManager, StreamFactory $streamFactory[, StreamInterface $stream = null ][, StreamInterface $contentStream = null ]) : mixed
Parameters
- $partStreamFilterManager : PartStreamFilterManager
- $streamFactory : StreamFactory
- $stream : StreamInterface = null
- $contentStream : StreamInterface = null
Return values
mixed —__destruct()
Overridden to close streams.
public
__destruct() : mixed
Return values
mixed —__toString()
Returns the message/part as a string.
public
__toString() : string
Convenience method for calling getStream()->getContents().
Return values
string —attachContentStream()
Attaches the stream or resource handle for the part's content. The stream is closed when another stream is attached, or the MimePart is destroyed.
public
attachContentStream(StreamInterface $stream[, string $streamCharset = MailMimeParser::DEFAULT_CHARSET ]) : mixed
Parameters
- $stream : StreamInterface
- $streamCharset : string = MailMimeParser::DEFAULT_CHARSET
Return values
mixed —detachContentStream()
Detaches and closes the content stream.
public
detachContentStream() : mixed
Return values
mixed —getCharset()
Returns ISO-8859-1
public
getCharset() : string
Return values
string —getContent()
Shortcut to reading stream content and assigning it to a string. Returns null if the part doesn't have a content stream.
public
getContent([string $charset = MailMimeParser::DEFAULT_CHARSET ]) : string
The returned string is encoded to the passed $charset character encoding, defaulting to UTF-8.
Parameters
- $charset : string = MailMimeParser::DEFAULT_CHARSET
Return values
string —getContentDisposition()
Returns 'inline'.
public
getContentDisposition() : string
Return values
string —getContentResourceHandle()
Returns a new resource stream handle for the part's content or null if the part doesn't have a content section.
public
getContentResourceHandle([string $charset = MailMimeParser::DEFAULT_CHARSET ]) : resource
The returned resource handle is a resource stream with decoding filters appended to it. The attached filters are determined by looking at the part's Content-Transfer-Encoding and Content-Type headers unless a charset override is set. The following transfer encodings are supported:
- quoted-printable
- base64
- x-uuencode
In addition, the charset of the underlying stream is converted to the passed $charset if the content is known to be text.
Parameters
- $charset : string = MailMimeParser::DEFAULT_CHARSET
Return values
resource —getContentStream()
Returns the StreamInterface for the part's content or null if the part doesn't have a content section.
public
getContentStream([string $charset = MailMimeParser::DEFAULT_CHARSET ]) : StreamInterface
Because the returned stream may be a shared object if called multiple times, the function isn't exposed publicly. If called multiple times with the same $charset, and the value of the part's Content-Transfer-Encoding header not having changed, the returned stream is the same instance and may need to be rewound.
Note that PartStreamFilterManager rewinds the stream before returning it.
Parameters
- $charset : string = MailMimeParser::DEFAULT_CHARSET
Return values
StreamInterface —getContentTransferEncoding()
Returns '7bit'.
public
getContentTransferEncoding() : string
Return values
string —getContentType()
Returns text/plain
public
getContentType() : string
Return values
string —getFilename()
Returns a filename for the part if one is defined, or null otherwise.
public
getFilename() : string
Return values
string —getParent()
Returns this part's parent.
public
getParent() : MimePart
Return values
MimePart —getResourceHandle()
Rewrite me
public
getResourceHandle() : resource
Return values
resource —the resource handle
getStream()
Write me
public
getStream() : StreamInterface
Return values
StreamInterface —the resource handle
hasContent()
Returns true if there's a content stream associated with the part.
public
hasContent() : bool
Return values
bool —isMime()
Returns false.
public
isMime() : bool
Return values
bool —isTextPart()
Returns true.
public
isTextPart() : bool
Return values
bool —markAsChanged()
Marks the part as changed, forcing the part to be rewritten when saved.
public
markAsChanged() : mixed
Normal operations to a MessagePart automatically mark the part as changed and markAsChanged() doesn't need to be called in those cases.
The function can be called to indicate an external change that requires rewriting this part, for instance changing a message from a non-mime message to a mime one, would require rewriting non-mime children to insure suitable headers are written.
Internally, the function discards the part's stream, forcing a stream to be created when calling getStream().
Return values
mixed —save()
Saves the message/part as to the passed resource handle.
public
save(resource|StreamInterface $streamOrHandle) : mixed
Parameters
- $streamOrHandle : resource|StreamInterface
Return values
mixed —setCharsetOverride()
Overrides the default character set used for reading content from content streams in cases where a user knows the source charset is not what is specified.
public
setCharsetOverride(string $charsetOverride[, bool $onlyIfNoCharset = false ]) : mixed
If set, the returned value from MessagePart::getCharset is ignored.
Note that setting an override on a Message and calling getTextStream, getTextContent, getHtmlStream or getHtmlContent will not be applied to those sub-parts, unless the text/html part is the Message itself. Instead, Message:getTextPart() should be called, and setCharsetOverride called on the returned MessagePart.
Parameters
- $charsetOverride : string
- $onlyIfNoCharset : bool = false
-
if true, $charsetOverride is used only if getCharset returns null.
Return values
mixed —setContent()
Sets the content of the part to the passed resource.
public
setContent(string|resource|StreamInterface $resource[, string $charset = MailMimeParser::DEFAULT_CHARSET ]) : mixed
Parameters
- $resource : string|resource|StreamInterface
- $charset : string = MailMimeParser::DEFAULT_CHARSET
Return values
mixed —onChange()
Called when operations change the content of the MessagePart.
protected
onChange() : mixed
The function causes calls to getStream() to return a dynamic MessagePartStream instead of the read stream for this MessagePart and all parent MessageParts.