Module.php 1.47 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5
<?php
class Doctrine_Module implements IteratorAggregate, Countable {
    /**
     * @var array $components   an array containing all the components in this module
     */
6
    protected $components = array();
doctrine's avatar
doctrine committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    /**
     * @var string $name        the name of this module
     */
    private $name;
    /**
     * constructor
     *
     * @param string $name      the name of this module
     */
    public function __construct($name) {
        $this->name = $name;
    }
    /**
     * returns the name of this module
     *
     * @return string
     */
    public function getName() {
        return $this->name;
    }
    /**
     * flush
     * saves all components
     *
     * @return void
     */
    public function flush() {
        $session = Doctrine_Manager::getInstance()->getCurrentSession();
        
        $tree = $session->buildFlushTree($this->components);
    }
    /**
     * getIterator
     * this class implements IteratorAggregate interface
     * returns an iterator that iterates through the components
     * in this module
     *
     * @return ArrayIterator
     */
    public function getIterator() {
        return new ArrayIterator($this->components);
    }
    /**
     * count
     * this class implements Countable interface
     * returns the number of components in this module
     *
     * @return integer
     */
    public function count() {
        return count($this->components);
    }
}
?>