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 item list
4
 *
5
 * @package Services_Ebay
6
 * @author  Stephan Schmidt <schst@php.net>
7
 */
8
class Services_Ebay_Model_ItemList extends Services_Ebay_Model implements IteratorAggregate
9
{
10
   /**
11
    * items of the list
12
    *
13
    * @var  array
14
    */
15
    private $items = array();
16
 
17
   /**
18
    * create a new item list
19
    *
20
    * @param    array   properties
21
    * @param    object Services_Ebay_Session
22
    */
23
    public function __construct($props, $session = null)
24
    {
25
        if (isset($props['Item'])) {
26
            if ( is_array($props['Item'])) {
27
                if (!isset($props['Item'][0])) {
28
                    $props['Item'] = array($props['Item']);
29
                }
30
                foreach ($props['Item'] as $item) {
31
                    array_push( $this->items, Services_Ebay::loadModel('Item', $item, $session) );
32
                }
33
            }
34
            unset($props['Item']);
35
        }
36
 
37
        parent::__construct($props, $session);
38
    }
39
 
40
   /**
41
    * get the iterator for the items in the list
42
    *
43
    * @return   object
44
    */
45
    public function getIterator()
46
    {
47
        $iterator = new ArrayObject($this->items);
48
        return $iterator;
49
    }
50
}
51
?>