1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/lib/Doctrine/Resource.php
2007-09-22 01:32:48 +00:00

34 lines
939 B
PHP

<?php
class Doctrine_Resource
{
public static function request($url, $request)
{
$url .= strstr($url, '?') ? '&':'?';
$url .= http_build_query($request);
$response = file_get_contents($url);
return $response;
}
public function hydrate(array $array, $model, $config, $passedKey = null)
{
$collection = new Doctrine_Resource_Collection($model, $config);
foreach ($array as $record) {
$r = new Doctrine_Resource_Record($model, $config);
foreach ($record as $key => $value) {
if (is_array($value)) {
$r->data[$key] = $this->hydrate($value, $model, $config, $key);
} else {
$r->data[$key] = $value;
}
}
$collection->data[] = $r;
}
return $collection;
}
}