ParserManager
in package
Manages a prioritized list of IParser objects for parsing messages and parts and creating proxied parts.
The default ParserManager sets up a MimeParser in priority 0, and a NonMimeParser in priority 1.
Tags
Table of Contents
- $parsers : array<string|int, IParser>
- __construct() : mixed
- createParserProxyFor() : ParserPartProxy|null
- Creates a ParserPartProxy for the passed $partBuilder using a compatible IParser.
- prependParser() : self
- Adds an IParser at the highest priority (up front), calling $parser->setParserManager($this) on it.
- setParsers() : self
- Overrides the internal prioritized list of parses with the passed list, calling $parser->setParserManager($this) on each one.
Properties
$parsers
protected
array<string|int, IParser>
$parsers
= []
List of parsers in order of priority (0 is highest priority).
Methods
__construct()
public
__construct(MimeParser $mimeParser, NonMimeParser $nonMimeParser) : mixed
Parameters
- $mimeParser : MimeParser
- $nonMimeParser : NonMimeParser
Return values
mixed —createParserProxyFor()
Creates a ParserPartProxy for the passed $partBuilder using a compatible IParser.
public
createParserProxyFor(PartBuilder $partBuilder) : ParserPartProxy|null
Loops through registered IParsers calling 'canParse()' on each with the passed PartBuilder, then calling either 'getParserMessageProxyFactory()' or 'getParserPartProxyFactory()' depending on if the PartBuilder has a parent, and finally calling 'newInstance' on the returned ParserPartProxyFactory passing it the IParser, and returning the new ParserPartProxy instance that was created.
Parameters
- $partBuilder : PartBuilder
-
The PartBuilder to wrap in a proxy with an IParser
Return values
ParserPartProxy|null —The created ParserPartProxy tied to a new IMessagePart and associated IParser.
prependParser()
Adds an IParser at the highest priority (up front), calling $parser->setParserManager($this) on it.
public
prependParser(IParser $parser) : self
Parameters
- $parser : IParser
-
The parser to add.
Return values
self —setParsers()
Overrides the internal prioritized list of parses with the passed list, calling $parser->setParserManager($this) on each one.
public
setParsers(array<string|int, mixed> $parsers) : self
Parameters
- $parsers : array<string|int, mixed>