Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?PHP
2
/**
3
 * Model for a search result
4
 *
5
 *
6
 * @package Services_Ebay
7
 * @author  Stephan Schmidt <schst@php.net>
8
 */
9
class Services_Ebay_Model_SearchResult extends Services_Ebay_Model implements IteratorAggregate
10
{
11
   /**
12
    * items that have been found
13
    *
14
    * @var  array
15
    */
16
    private $items = array();
17
 
18
   /**
19
    * create new model
20
    *
21
    * @param    array
22
    * @param    object
23
    */
24
    public function __construct($props, $session = null)
25
    {
26
        if (isset($props['Items'])) {
27
            $items = $props['Items'];
28
            unset($props['Items']);
29
            if (isset($items['Item'][0])) {
30
                $items = $items['Item'];
31
            } else {
32
                $items = array($items['Item']);
33
            }
34
            foreach ($items as $tmp) {
35
                array_push($this->items, Services_Ebay::loadModel('Item', $tmp, $session));
36
            }
37
        }
38
        parent::__construct($props, $session);
39
    }
40
 
41
   /**
42
    * iterate through the items
43
    *
44
    * @return   object
45
    */
46
    public function getIterator()
47
    {
48
        $it = new ArrayObject($this->items);
49
        return $it;
50
    }
51
}
52
?>