MimeParserService
extends AbstractParserService
in package
Parses content and children of MIME parts.
Tags
Table of Contents
- $headerParser : HeaderParserService
- $parserManager : ParserManagerService
- $parserMessageProxyFactory : ParserPartProxyFactory
- $parserPartProxyFactory : ParserPartProxyFactory
- $partBuilderFactory : PartBuilderFactory
- $partHeaderContainerFactory : PartHeaderContainerFactory
- __construct() : mixed
- canParse() : bool
- Returns true if the passed PartBuilder::isMime() method returns true.
- getParserMessageProxyFactory() : ParserPartProxyFactory
- Returns the ParserPartProxyFactory responsible for creating IMessage parts for this parser.
- getParserPartProxyFactory() : ParserPartProxyFactory
- Returns the ParserPartProxyFactory responsible for creating IMessagePart parts for this parser.
- parseContent() : static
- parseNextChild() : ParserPartProxy|null
- setParserManager() : static
- Sets up the passed ParserManager as the ParserManager for this part, which should be used when a new part is created (after its headers are read and a PartBuilder is created from it.)
- createPart() : ParserPartProxy|null
- Calls the header parser to fill the passed $headerContainer, then calls $this->parserManager->createParserProxyFor($child);
- findContentBoundary() : static
- Reads 2048-byte lines from the passed $handle, calling $partBuilder->setEndBoundaryFound with the passed line until it returns true or the stream is at EOF.
- readBoundaryLine() : string
- Reads up to 2048 bytes of input from the passed resource handle, discarding portions of a line that are longer than that, and returning the read portions of the line.
Properties
$headerParser
protected
HeaderParserService
$headerParser
The HeaderParser service.
$parserManager
protected
ParserManagerService
$parserManager
the ParserManager, which should call setParserManager when the parser is added.
$parserMessageProxyFactory
protected
ParserPartProxyFactory
$parserMessageProxyFactory
the parser's message proxy factory service responsible for creating an IMessage part wrapped in a ParserPartProxy.
$parserPartProxyFactory
protected
ParserPartProxyFactory
$parserPartProxyFactory
the parser's part proxy factory service responsible for creating IMessagePart parts wrapped in a ParserPartProxy.
$partBuilderFactory
protected
PartBuilderFactory
$partBuilderFactory
Service for creating PartBuilder objects for new children.
$partHeaderContainerFactory
protected
PartHeaderContainerFactory
$partHeaderContainerFactory
Factory service for creating PartHeaderContainers for headers.
Methods
__construct()
public
__construct(ParserMessageProxyFactory $parserMessageProxyFactory, ParserMimePartProxyFactory $parserMimePartProxyFactory, PartBuilderFactory $partBuilderFactory, PartHeaderContainerFactory $partHeaderContainerFactory, HeaderParserService $headerParser) : mixed
Parameters
- $parserMessageProxyFactory : ParserMessageProxyFactory
- $parserMimePartProxyFactory : ParserMimePartProxyFactory
- $partBuilderFactory : PartBuilderFactory
- $partHeaderContainerFactory : PartHeaderContainerFactory
- $headerParser : HeaderParserService
Return values
mixed —canParse()
Returns true if the passed PartBuilder::isMime() method returns true.
public
canParse(PartBuilder $part) : bool
Parameters
- $part : PartBuilder
Return values
bool —getParserMessageProxyFactory()
Returns the ParserPartProxyFactory responsible for creating IMessage parts for this parser.
public
getParserMessageProxyFactory() : ParserPartProxyFactory
This is called by ParserManager after 'canParse' if it returns true so a ParserPartProxy can be created out of the PartBuilder.
Return values
ParserPartProxyFactory —getParserPartProxyFactory()
Returns the ParserPartProxyFactory responsible for creating IMessagePart parts for this parser.
public
getParserPartProxyFactory() : ParserPartProxyFactory
This is called by ParserManager after 'canParse' if it returns true so a ParserPartProxy can be created out of the PartBuilder.
Return values
ParserPartProxyFactory —parseContent()
public
parseContent(ParserPartProxy $proxy) : static
Parameters
- $proxy : ParserPartProxy
Return values
static —parseNextChild()
public
parseNextChild(ParserMimePartProxy $proxy) : ParserPartProxy|null
Parameters
- $proxy : ParserMimePartProxy
Return values
ParserPartProxy|null —setParserManager()
Sets up the passed ParserManager as the ParserManager for this part, which should be used when a new part is created (after its headers are read and a PartBuilder is created from it.)
public
setParserManager(ParserManagerService $pm) : static
Parameters
- $pm : ParserManagerService
-
The ParserManager to set.
Return values
static —createPart()
Calls the header parser to fill the passed $headerContainer, then calls $this->parserManager->createParserProxyFor($child);
private
createPart(ParserMimePartProxy $parent, PartHeaderContainer $headerContainer, PartBuilder $child) : ParserPartProxy|null
The method first checks though if the 'part' represents hidden content past a MIME end boundary, which some messages like to include, for instance:
--outer-boundary--
--boundary
content
--boundary--
some hidden information
--outer-boundary--
In this case, $this->parserPartProxyFactory is called directly to create a part, $this->parseContent is called immediately to parse it and discard it, and null is returned.
Parameters
- $parent : ParserMimePartProxy
- $headerContainer : PartHeaderContainer
- $child : PartBuilder
Return values
ParserPartProxy|null —findContentBoundary()
Reads 2048-byte lines from the passed $handle, calling $partBuilder->setEndBoundaryFound with the passed line until it returns true or the stream is at EOF.
private
findContentBoundary(ParserMimePartProxy $proxy) : static
setEndBoundaryFound returns true if the passed line matches a boundary for the $partBuilder itself or any of its parents.
Lines longer than 2048 bytes are returned as single lines of 2048 bytes, the longer line is not returned separately but is simply discarded.
Once a boundary is found, setStreamPartAndContentEndPos is called with the passed $handle's read pos before the boundary and its line separator were read.
Parameters
- $proxy : ParserMimePartProxy
Return values
static —readBoundaryLine()
Reads up to 2048 bytes of input from the passed resource handle, discarding portions of a line that are longer than that, and returning the read portions of the line.
private
readBoundaryLine(resource $handle, ParserMimePartProxy $proxy) : string
The method also calls $proxy->setLastLineEndingLength which is used in findContentBoundary() to set the exact end byte of a part.
Parameters
- $handle : resource
- $proxy : ParserMimePartProxy