Commit a1b4b0f7 authored by zYne's avatar zYne

Simplified object population

parent 5de6c0a6
...@@ -520,41 +520,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator ...@@ -520,41 +520,6 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
return true; return true;
} }
/**
* populate
*
* @param Doctrine_Query $query
* @param integer $key
*/
public function populate(Doctrine_Hydrate $query) {
$name = $this->table->getComponentName();
if($this instanceof Doctrine_Collection_Immediate ||
$this instanceof Doctrine_Collection_Offset) {
$data = $query->getData($name);
if(is_array($data)) {
foreach($data as $k=>$v):
$this->table->setData($v);
$this->add($this->table->getRecord());
endforeach;
}
} elseif($this instanceof Doctrine_Collection_Batch) {
$this->data = $query->getData($name);
if(isset($this->keyColumn)) {
foreach($this->data as $k => $v) {
$value = $record->get($this->keyColumn);
if($value === null)
throw new Doctrine_Collection_Exception("Couldn't create collection index. Record field '".$this->keyColumn."' was null.");
$this->data[$value] = $record;
unset($this->data[$k]);
}
}
}
}
/** /**
* loadRelated * loadRelated
* *
......
...@@ -222,20 +222,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { ...@@ -222,20 +222,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
throw new Doctrine_Exception("Unknown fetchmode"); throw new Doctrine_Exception("Unknown fetchmode");
endswitch; endswitch;
$coll->populate($this);
return $coll; return $coll;
} }
/**
* getData
* @param $key the component name
* @return array the data row for the specified component
*/
final public function getData($key) {
if(isset($this->data[$key]) && is_array($this->data[$key]))
return $this->data[$key];
return array();
}
/** /**
* convertBoolean * convertBoolean
* converts boolean to integers * converts boolean to integers
...@@ -255,7 +243,6 @@ abstract class Doctrine_Hydrate extends Doctrine_Access { ...@@ -255,7 +243,6 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
* @return Doctrine_Collection the root collection * @return Doctrine_Collection the root collection
*/ */
public function execute($params = array(), $return = Doctrine::FETCH_RECORD) { public function execute($params = array(), $return = Doctrine::FETCH_RECORD) {
$this->data = array();
$this->collections = array(); $this->collections = array();
array_walk($params, array(__CLASS__, 'convertBoolean')); array_walk($params, array(__CLASS__, 'convertBoolean'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment