ソースを参照

Zend_Feed_Pubsubhubbub: added a Subscription Model interface for end-users to implement and updated API comments to reflect

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19846 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 年 前
コミット
1c22d4cf26

+ 8 - 8
library/Zend/Feed/Pubsubhubbub/CallbackAbstract.php

@@ -40,11 +40,11 @@ abstract class Zend_Feed_Pubsubhubbub_CallbackAbstract
     implements Zend_Feed_Pubsubhubbub_CallbackInterface
 {
     /**
-     * An instance of Zend_Feed_Pubsubhubbub_Model_ModelAbstract used 
+     * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used 
      * to background save any verification tokens associated with a subscription
      * or other.
      *
-     * @var Zend_Feed_Pubsubhubbub_Model_ModelAbstract
+     * @var Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      */
     protected $_storage = null;
 
@@ -113,32 +113,32 @@ abstract class Zend_Feed_Pubsubhubbub_CallbackAbstract
     }
 
     /**
-     * Sets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used
+     * Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used
      * to background save any verification tokens associated with a subscription
      * or other.
      *
-     * @param  Zend_Feed_Pubsubhubbub_Storage_StorageInterface $storage
+     * @param  Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage
      * @return Zend_Feed_Pubsubhubbub_CallbackAbstract
      */
-    public function setStorage(Zend_Feed_Pubsubhubbub_Model_ModelAbstract $storage)
+    public function setStorage(Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage)
     {
         $this->_storage = $storage;
         return $this;
     }
 
     /**
-     * Gets an instance of Zend_Feed_Pubsubhubbub_Storage_StorageInterface used
+     * Gets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used
      * to background save any verification tokens associated with a subscription
      * or other.
      *
-     * @return Zend_Feed_Pubsubhubbub_Model_ModelAbstract
+     * @return Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      */
     public function getStorage()
     {
         if ($this->_storage === null) {
             require_once 'Zend/Feed/Pubsubhubbub/Exception.php';
             throw new Zend_Feed_Pubsubhubbub_Exception('No storage object has been'
-                . ' set that subclasses Zend_Feed_Pubsubhubbub_Model_ModelAbstract');
+                . ' set that subclasses Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface');
         }
         return $this->_storage;
     }

+ 4 - 0
library/Zend/Feed/Pubsubhubbub/Model/Subscription.php

@@ -22,6 +22,9 @@
 /** @see Zend_Feed_Pubsubhubbub_Model_ModelAbstract */
 require_once 'Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php';
 
+/** @see Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface */
+require_once 'Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php';
+
 /**
  * @category   Zend
  * @package    Zend_Feed_Pubsubhubbub
@@ -31,6 +34,7 @@ require_once 'Zend/Feed/Pubsubhubbub/Model/ModelAbstract.php';
  */
 class Zend_Feed_Pubsubhubbub_Model_Subscription
     extends Zend_Feed_Pubsubhubbub_Model_ModelAbstract
+    implements Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
 {
     
     /**

+ 64 - 0
library/Zend/Feed/Pubsubhubbub/Model/SubscriptionInterface.php

@@ -0,0 +1,64 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Feed_Pubsubhubbub
+ * @subpackage Entity
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+/**
+ * @category   Zend
+ * @package    Zend_Feed_Pubsubhubbub
+ * @subpackage Entity
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+interface Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
+{
+    
+    /**
+     * Save subscription to RDMBS
+     *
+     * @param array $data The key must be stored here as a $data['id'] entry
+     * @return bool
+     */
+    public function setSubscription(array $data);
+    
+    /**
+     * Get subscription by ID/key
+     * 
+     * @param  string $key 
+     * @return array
+     */
+    public function getSubscription($key);
+
+    /**
+     * Determine if a subscription matching the key exists
+     * 
+     * @param  string $key 
+     * @return bool
+     */
+    public function hasSubscription($key);
+    
+    /**
+     * Delete a subscription
+     *
+     * @param string $key
+     * @return bool
+     */
+    public function deleteSubscription($key);
+    
+}

+ 6 - 6
library/Zend/Feed/Pubsubhubbub/Subscriber.php

@@ -101,10 +101,10 @@ class Zend_Feed_Pubsubhubbub_Subscriber
     protected $_asyncHubs = array();
 
     /**
-     * An instance of Zend_Feed_Pubsubhubbub_Entity used to background
+     * An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background
      * save any verification tokens associated with a subscription or other.
      *
-     * @var Zend_Feed_Pubsubhubbub_Entity
+     * @var Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      */
     protected $_storage = null;
 
@@ -519,13 +519,13 @@ class Zend_Feed_Pubsubhubbub_Subscriber
     }
 
     /**
-     * Sets an instance of Zend_Feed_Pubsubhubbub_Entity used to background
+     * Sets an instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface used to background
      * save any verification tokens associated with a subscription or other.
      *
-     * @param  Zend_Feed_Pubsubhubbub_Entity $storage
+     * @param  Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage
      * @return Zend_Feed_Pubsubhubbub_Subscriber
      */
-    public function setStorage(Zend_Feed_Pubsubhubbub_Model_ModelAbstract $storage)
+    public function setStorage(Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface $storage)
     {
         $this->_storage = $storage;
         return $this;
@@ -536,7 +536,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber
      * to background save any verification tokens associated with a subscription
      * or other.
      *
-     * @return Zend_Feed_Pubsubhubbub_Storage_StorageInterface
+     * @return Zend_Feed_Pubsubhubbub_Model_SubscriptionInterface
      */
     public function getStorage()
     {

+ 1 - 1
tests/Zend/Feed/Pubsubhubbub/Subscriber/CallbackTest.php

@@ -141,7 +141,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
 
     public function testCanSetStorageImplementation()
     {
-	    $storage = new Zend_Feed_Pubsubhubbub_Model_ModelAbstract($this->_tableGateway);
+	    $storage = new Zend_Feed_Pubsubhubbub_Model_Subscription($this->_tableGateway);
         $this->_callback->setStorage($storage);
         $this->assertThat($this->_callback->getStorage(), $this->identicalTo($storage));
     }