Re-add a metadata store to Horde_Mime_Part
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 16:46:54 +0000 (09:46 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 16:51:23 +0000 (09:51 -0700)
framework/Mime/lib/Horde/Mime/Part.php

index 682a33d..4fe99a1 100644 (file)
@@ -159,6 +159,13 @@ class Horde_Mime_Part
     protected $_temp = array();
 
     /**
+     * Metadata.
+     *
+     * @var array
+     */
+    protected $_metadata = array();
+
+    /**
      * Unique Horde_Mime_Part boundary string.
      *
      * @var string
@@ -1357,6 +1364,35 @@ class Horde_Mime_Part
     }
 
     /**
+     * Set a piece of metadata on this object.
+     *
+     * @param string $key  The metadata key.
+     * @param mixed $data  The metadata. If null, clears the key.
+     */
+    public function setMetadata($key, $data = null)
+    {
+        if (is_null($data)) {
+            unset($this->_metadata[$key]);
+        } else {
+            $this->_metadata[$key] = $data;
+        }
+    }
+
+    /**
+     * Retrieves metadata from this object.
+     *
+     * @param string $key  The metadata key.
+     *
+     * @return mixed  The metadata, or null if it doesn't exist.
+     */
+    public function getMetadata($key)
+    {
+        return isset($this->_metadata[$key])
+            ? $this->_metadata[$key]
+            : null;
+    }
+
+    /**
      * Sends this message.
      *
      * @param string $email                The address list to send to.