TYPO3  7.6
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Swift_Mime_Headers_MailboxHeader Class Reference
Inheritance diagram for Swift_Mime_Headers_MailboxHeader:
Swift_Mime_Headers_AbstractHeader Swift_Mime_Header

Public Member Functions

 __construct ($name, Swift_Mime_HeaderEncoder $encoder, Swift_Mime_Grammar $grammar)
 
 getFieldType ()
 
 setFieldBodyModel ($model)
 
 getFieldBodyModel ()
 
 setNameAddresses ($mailboxes)
 
 getNameAddressStrings ()
 
 getNameAddresses ()
 
 setAddresses ($addresses)
 
 getAddresses ()
 
 removeAddresses ($addresses)
 
 getFieldBody ()
 
- Public Member Functions inherited from Swift_Mime_Headers_AbstractHeader
 __construct (Swift_Mime_Grammar $grammar)
 
 setCharset ($charset)
 
 getCharset ()
 
 setLanguage ($lang)
 
 getLanguage ()
 
 setEncoder (Swift_Mime_HeaderEncoder $encoder)
 
 getEncoder ()
 
 setGrammar (Swift_Mime_Grammar $grammar)
 
 getGrammar ()
 
 getFieldName ()
 
 setMaxLineLength ($lineLength)
 
 getMaxLineLength ()
 
 toString ()
 
 __toString ()
 

Protected Member Functions

 normalizeMailboxes (array $mailboxes)
 
 createDisplayNameString ($displayName, $shorten=false)
 
 createMailboxListString (array $mailboxes)
 
 tokenNeedsEncoding ($token)
 
- Protected Member Functions inherited from Swift_Mime_Headers_AbstractHeader
 setFieldName ($name)
 
 createPhrase (Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder=null, $shorten=false)
 
 encodeWords (Swift_Mime_Header $header, $input, $usedLength=-1)
 
 tokenNeedsEncoding ($token)
 
 getEncodableWordTokens ($string)
 
 getTokenAsEncodedWord ($token, $firstLineOffset=0)
 
 generateTokenLines ($token)
 
 setCachedValue ($value)
 
 getCachedValue ()
 
 clearCachedValueIf ($condition)
 
 toTokens ($string=null)
 

Private Member Functions

 _createNameAddressStrings (array $mailboxes)
 
 _assertValidAddress ($address)
 

Private Attributes

 $_mailboxes = array()
 

Additional Inherited Members

- Public Attributes inherited from Swift_Mime_Header
const TYPE_TEXT = 2
 
const TYPE_PARAMETERIZED = 6
 
const TYPE_MAILBOX = 8
 
const TYPE_DATE = 16
 
const TYPE_ID = 32
 
const TYPE_PATH = 64
 

Detailed Description

A Mailbox Address MIME Header for something like From or Sender.

Author
Chris Corbyn

Definition at line 16 of file MailboxHeader.php.

Constructor & Destructor Documentation

__construct (   $name,
Swift_Mime_HeaderEncoder  $encoder,
Swift_Mime_Grammar  $grammar 
)

Creates a new MailboxHeader with $name.

Parameters
string$nameof Header
Swift_Mime_HeaderEncoder$encoder
Swift_Mime_Grammar$grammar

Definition at line 32 of file MailboxHeader.php.

References Swift_Mime_Headers_AbstractHeader\setEncoder(), and Swift_Mime_Headers_AbstractHeader\setFieldName().

Member Function Documentation

_assertValidAddress (   $address)
private

Throws an Exception if the address passed does not comply with RFC 2822.

Parameters
string$address
Exceptions
Swift_RfcComplianceExceptionIf invalid.

Definition at line 344 of file MailboxHeader.php.

References Swift_Mime_Headers_AbstractHeader\getGrammar().

Referenced by normalizeMailboxes().

_createNameAddressStrings ( array  $mailboxes)
private

Return an array of strings conforming the the name-addr spec of RFC 2822.

Parameters
string[]$mailboxes
Returns
string[]

Definition at line 321 of file MailboxHeader.php.

References createDisplayNameString().

Referenced by createMailboxListString(), and getNameAddressStrings().

createDisplayNameString (   $displayName,
  $shorten = false 
)
protected

Produces a compliant, formatted display-name based on the string given.

Parameters
string$displayNameas displayed
bool$shortenthe first line to make remove for header name
Returns
string

Definition at line 278 of file MailboxHeader.php.

References Swift_Mime_Headers_AbstractHeader\createPhrase(), Swift_Mime_Headers_AbstractHeader\getCharset(), and Swift_Mime_Headers_AbstractHeader\getEncoder().

Referenced by _createNameAddressStrings().

createMailboxListString ( array  $mailboxes)
protected

Creates a string form of all the mailboxes in the passed array.

Parameters
string[]$mailboxes
Exceptions
Swift_RfcComplianceException
Returns
string

Definition at line 294 of file MailboxHeader.php.

References _createNameAddressStrings().

Referenced by getFieldBody().

getAddresses ( )

Get all email addresses in this Header.

See Also
getNameAddresses()
Returns
string[]

Definition at line 201 of file MailboxHeader.php.

getFieldBody ( )

Get the string value of the body in this Header.

This is not necessarily RFC 2822 compliant since folding white space will not be added at this stage (see toString() for that).

See Also
toString()
Exceptions
Swift_RfcComplianceException
Returns
string

Implements Swift_Mime_Header.

Definition at line 231 of file MailboxHeader.php.

References createMailboxListString(), Swift_Mime_Headers_AbstractHeader\getCachedValue(), and Swift_Mime_Headers_AbstractHeader\setCachedValue().

getFieldBodyModel ( )

Get the model for the field body.

This method returns an associative array like getNameAddresses()

Exceptions
Swift_RfcComplianceException
Returns
array

Implements Swift_Mime_Header.

Definition at line 75 of file MailboxHeader.php.

References getNameAddresses().

getFieldType ( )

Get the type of Header that this instance represents.

See Also
TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX
TYPE_DATE, TYPE_ID, TYPE_PATH
Returns
int

Implements Swift_Mime_Header.

Definition at line 47 of file MailboxHeader.php.

getNameAddresses ( )

Get all mailboxes in this Header as key=>value pairs.

The key is the address and the value is the name (or null if none set). Example: <?php $header = new Swift_Mime_Headers_MailboxHeader('From', array('chris.nosp@m.@swi.nosp@m.ftmai.nosp@m.ler..nosp@m.org' => 'Chris Corbyn', 'mark@.nosp@m.swif.nosp@m.tmail.nosp@m.er.o.nosp@m.rg' => 'Mark Corbyn') ); print_r($header->getNameAddresses()); // array ( // chris.nosp@m.@swi.nosp@m.ftmai.nosp@m.ler..nosp@m.org => Chris Corbyn, // mark@.nosp@m.swif.nosp@m.tmail.nosp@m.er.o.nosp@m.rg => Mark Corbyn // ) ?>

See Also
getAddresses()
getNameAddressStrings()
Returns
string[]

Definition at line 164 of file MailboxHeader.php.

References $_mailboxes.

Referenced by getFieldBodyModel(), and getNameAddressStrings().

getNameAddressStrings ( )

Get the full mailbox list of this Header as an array of valid RFC 2822 strings.

Example: <?php $header = new Swift_Mime_Headers_MailboxHeader('From', array('chris.nosp@m.@swi.nosp@m.ftmai.nosp@m.ler..nosp@m.org' => 'Chris Corbyn', 'mark@.nosp@m.swif.nosp@m.tmail.nosp@m.er.o.nosp@m.rg' => 'Mark Corbyn') ); print_r($header->getNameAddressStrings()); // array ( // 0 => Chris Corbyn chris.nosp@m.@swi.nosp@m.ftmai.nosp@m.ler..nosp@m.org, // 1 => Mark Corbyn mark@.nosp@m.swif.nosp@m.tmail.nosp@m.er.o.nosp@m.rg // ) ?>

See Also
getNameAddresses()
toString()
Exceptions
Swift_RfcComplianceException
Returns
string[]

Definition at line 135 of file MailboxHeader.php.

References _createNameAddressStrings(), and getNameAddresses().

normalizeMailboxes ( array  $mailboxes)
protected

Normalizes a user-input list of mailboxes into consistent key=>value pairs.

Parameters
string[]$mailboxes
Returns
string[]

Definition at line 250 of file MailboxHeader.php.

References _assertValidAddress().

Referenced by setNameAddresses().

removeAddresses (   $addresses)

Remove one or more addresses from this Header.

Parameters
string|string[]$addresses

Definition at line 211 of file MailboxHeader.php.

References Swift_Mime_Headers_AbstractHeader\setCachedValue().

setAddresses (   $addresses)

Makes this Header represent a list of plain email addresses with no names.

Example: <?php //Sets three email addresses as the Header data $header->setAddresses( array('one@d.nosp@m.omai.nosp@m.n.tld', 'two@d.nosp@m.omai.nosp@m.n.tld', 'three.nosp@m.@dom.nosp@m.ain.t.nosp@m.ld') ); ?>

See Also
setNameAddresses()
setValue()
Parameters
string[]$addresses
Exceptions
Swift_RfcComplianceException

Definition at line 189 of file MailboxHeader.php.

References setNameAddresses().

setFieldBodyModel (   $model)

Set the model for the field body.

This method takes a string, or an array of addresses.

Parameters
mixed$model
Exceptions
Swift_RfcComplianceException

Implements Swift_Mime_Header.

Definition at line 61 of file MailboxHeader.php.

References setNameAddresses().

setNameAddresses (   $mailboxes)

Set a list of mailboxes to be shown in this Header.

The mailboxes can be a simple array of addresses, or an array of key=>value pairs where (email => personalName). Example: <?php //Sets two mailboxes in the Header, one with a personal name $header->setNameAddresses(array( 'chris.nosp@m.@swi.nosp@m.ftmai.nosp@m.ler..nosp@m.org' => 'Chris Corbyn', 'mark@.nosp@m.swif.nosp@m.tmail.nosp@m.er.o.nosp@m.rg' //No associated personal name )); ?>

See Also
__construct()
setAddresses()
setValue()
Parameters
string|string[]$mailboxes
Exceptions
Swift_RfcComplianceException

Definition at line 104 of file MailboxHeader.php.

References normalizeMailboxes(), and Swift_Mime_Headers_AbstractHeader\setCachedValue().

Referenced by setAddresses(), and setFieldBodyModel().

tokenNeedsEncoding (   $token)
protected

Redefine the encoding requirements for mailboxes.

Commas and semicolons are used to separate multiple addresses, and should therefore be encoded

Parameters
string$token
Returns
bool

Definition at line 309 of file MailboxHeader.php.

Member Data Documentation

$_mailboxes = array()
private

Definition at line 23 of file MailboxHeader.php.

Referenced by getNameAddresses().