Hello,

there are lots of nice approaches out there how to setup models and
databases and i really like the idea with the data mapper pattern as
described in the official zend framework quickstart tutorial.

But what i am missing is also an example for webservices. How would you
setup a model to handle a soap/rest request? Is a Data Mapper also useful if
you only need to read data? 

For example i want to fetch some items from several shopping provider. Does
this one makes sense? Isnt this too much overhead?

So what would be a good solution if you have different providers but always
want to return the same Item object? Add another method to
Default_Model_Item, for example fetchAllFromProvider2()?

Thank you in advance for your replies.

class Default_Model_Item
{
 protected $_title;
 protected $_price;
 protected $_description;

 // getter setter 
 public function getXXX()
 public function setXXX()

 public function find($id);
 
 // different providers
 public function fetchAllFromProvider1($options);
 public function fetchAllFromProvider2($options);
}

class Default_Model_ItemMapper
{
   public function find($id, $model);

   public function fetchAllFromProvider1($options)
   {
     $provider = new Default_Model_Webservice_ShoppingProvider1();
     $listings = $provider->makeCall($options);
     foreach($listings as $item) 
     {
      $entry = new Default_Model_Item();
      $entry->setTitle();
      $entry->setPrice();
      $entry->setDescription();
      }
   }

   public function fetchAllFromProvider2($options)
   {
     $provider = new Default_Model_Webservice_ShoppingProvider2();
     $listings = $provider->makeCall($options);
     foreach($listings as $item) 
     {
      $entry = new Default_Model_Item();
      $entry->setTitle();
      $entry->setPrice();
      $entry->setDescription();
      }
   }
  
}

class Default_Model_Webservice_ShoppingProvider1 {
 public function makeCall($options)
}

class Default_Model_Webservice_ShoppingProvider2 {
 public function makeCall($options)
}
-- 
View this message in context: 
http://www.nabble.com/Zend-Model-with-Webservices-%28Soap-Rest%29-tp24689665p24689665.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to