2007-09-21 18:01:08 +00:00
|
|
|
<?php
|
|
|
|
class Doctrine_Resource_Collection extends Doctrine_Access implements Countable, IteratorAggregate
|
|
|
|
{
|
|
|
|
public $data = array();
|
|
|
|
public $config = array();
|
|
|
|
public $model = null;
|
|
|
|
|
2007-09-21 18:19:19 +00:00
|
|
|
public function __construct($model)
|
|
|
|
{
|
|
|
|
$this->model = $model;
|
|
|
|
}
|
|
|
|
|
2007-09-21 18:01:08 +00:00
|
|
|
public function count()
|
|
|
|
{
|
|
|
|
return count($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIterator()
|
|
|
|
{
|
|
|
|
$data = $this->data;
|
|
|
|
|
|
|
|
return new ArrayIterator($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFirst()
|
|
|
|
{
|
|
|
|
return $this->data[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function toArray()
|
|
|
|
{
|
|
|
|
$array = array();
|
2007-09-21 18:34:10 +00:00
|
|
|
foreach ($this->data as $key => $record) {
|
2007-09-21 18:01:08 +00:00
|
|
|
$array[$key] = $record->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $array;
|
|
|
|
}
|
2007-09-21 18:34:10 +00:00
|
|
|
|
|
|
|
public function save()
|
|
|
|
{
|
|
|
|
foreach ($this->data as $record) {
|
|
|
|
$record->save();
|
|
|
|
}
|
|
|
|
}
|
2007-09-21 18:01:08 +00:00
|
|
|
}
|