public function testDefaultConstructor() { $p = new Part(); $this->assertNull($p->getContent()); $this->assertEquals('application/octet-stream', $p->getHeader('Content-Type')); $this->assertEquals('utf-8', $p->getHeader('Content-Type', 'charset')); $this->assertEquals(Part::ENCODING_BINARY, $p->getHeader('Content-Transfer-Encoding')); $this->assertRegExp('~<urn:uuid:.*>~', $p->getHeader('Content-ID')); }
/** * {@inheritDoc} */ public function convertPhpToXml($data) { $part = new MimePart($data); $contentId = trim($part->getHeader('Content-ID'), '<>'); $this->soapKernel->addAttachment($part); return sprintf('<%s href="%s"/>', $this->getTypeName(), 'cid:' . $contentId); }
/** * {@inheritDoc} */ public function convertPhpToXml($data) { $part = new MimePart($data); $contentId = trim($part->getHeader('Content-ID'), '<>'); $this->soapKernel->addAttachment($part); $doc = new \DOMDocument(); $node = $doc->createElement($this->getTypeName()); $doc->appendChild($node); // add xop:Include element $xinclude = $doc->createElementNS(Helper::NS_XOP, Helper::PFX_XOP . ':Include'); $xinclude->setAttribute('href', 'cid:' . $contentId); $node->appendChild($xinclude); return $doc->saveXML(); }
/** * Add attachment. * * @param \BeSimple\SoapCommon\Mime\Part $attachment New attachment * * @return void */ public function addAttachment(MimePart $attachment) { $contentId = trim($attachment->getHeader('Content-ID'), '<>'); $this->attachments[$contentId] = $attachment; }
/** * Add new part to MIME message. * * @param \BeSimple\SoapCommon\Mime\Part $part Part that is added * @param boolean $isMain Is the given part the main part of mime message * * @return void */ public function addPart(Part $part, $isMain = false) { $contentId = trim($part->getHeader('Content-ID'), '<>'); if ($isMain === true) { $this->mainPartContentId = $contentId; $this->setHeader('Content-Type', 'start', $part->getHeader('Content-ID')); } $this->parts[$contentId] = $part; }