_groupsById = array(); $this->_groupsByName = array(); foreach ($data->groups as $group) { $group = new Zend_Service_RememberTheMilk_Group($group); $this->_groupsById[$group->getId()] = $group; $this->_groupsByName[$group->getName()] = $group; } } /** * Implementation of IteratorAggregate::getIterator(). * * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_groupsById); } /** * Implementation of IteratorAggregate::getLength(). * * @return int */ public function getLength() { return count($this->_groupsById); } /** * Returns the group instance with the specified identifier. * * @param int $id Identifier for the group * @return Zend_Service_RememberTheMilk_Group */ public function getGroupById($id) { if (isset($this->_groupsById[$id])) { return $this->_groupsById[$id]; } return null; } /** * Returns the group instance with the specified name. * * @param string $name Name of the group * @return Zend_Service_RememberTheMilk_Group */ public function getGroupByName($name) { if (isset($this->_groupsByName[$name])) { return $this->_groupsByName[$name]; } return null; } }