From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/library/Zend/Gdata/App/MediaEntry.php | 119 +++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 zend/library/Zend/Gdata/App/MediaEntry.php (limited to 'zend/library/Zend/Gdata/App/MediaEntry.php') diff --git a/zend/library/Zend/Gdata/App/MediaEntry.php b/zend/library/Zend/Gdata/App/MediaEntry.php new file mode 100644 index 0000000..68b47b1 --- /dev/null +++ b/zend/library/Zend/Gdata/App/MediaEntry.php @@ -0,0 +1,119 @@ +_mediaSource = $mediaSource; + } + + /** + * Return the MIME multipart representation of this MediaEntry. + * + * @return string|Zend_Gdata_MediaMimeStream The MIME multipart + * representation of this MediaEntry. If the entry consisted only + * of XML, a string is returned. + */ + public function encode() + { + $xmlData = $this->saveXML(); + $mediaSource = $this->getMediaSource(); + if ($mediaSource === null) { + // No attachment, just send XML for entry + return $xmlData; + } else { + return new Zend_Gdata_MediaMimeStream($xmlData, + $mediaSource->getFilename(), $mediaSource->getContentType()); + } + } + + /** + * Return the MediaSource object representing the file attached to this + * MediaEntry. + * + * @return Zend_Gdata_App_MediaSource The attached MediaSource/file + */ + public function getMediaSource() + { + return $this->_mediaSource; + } + + /** + * Set the MediaSource object (file) for this MediaEntry + * + * @param Zend_Gdata_App_MediaSource $value The attached MediaSource/file + * @return Zend_Gdata_App_MediaEntry Provides a fluent interface + */ + public function setMediaSource($value) + { + if ($value instanceof Zend_Gdata_App_MediaSource) { + $this->_mediaSource = $value; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'You must specify the media data as a class that conforms to Zend_Gdata_App_MediaSource.'); + } + return $this; + } + +} -- cgit v1.2.3