Phalcon\Mailer\Message::prepareAttachment PHP Method

prepareAttachment() protected method

Prepare and attach the given attachment.
See also: Swift_Message::attach()
protected prepareAttachment ( Swift_Attachment $attachment, array $options = [] )
$attachment Swift_Attachment
$options array optional
    protected function prepareAttachment(\Swift_Attachment $attachment, array $options = [])
    {
        if (isset($options['mime'])) {
            $attachment->setContentType($options['mime']);
        }
        if (isset($options['as'])) {
            $attachment->setFilename($options['as']);
        }
        $eventManager = $this->getManager()->getEventsManager();
        if ($eventManager) {
            $result = $eventManager->fire('mailer:beforeAttachFile', $this, [$attachment]);
        } else {
            $result = true;
        }
        if ($result !== false) {
            $this->getMessage()->attach($attachment);
            if ($eventManager) {
                $eventManager->fire('mailer:afterAttachFile', $this, [$attachment]);
            }
        }
        return $this;
    }