. */ /** * Doctrine_Resource_Request * * @author Konsta Vesterinen * @author Jonathan H. Wage * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version $Revision$ * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 */ class Doctrine_Resource_Request extends Doctrine_Resource_Params { protected $_params = null; public function getConfig($key = null) { return Doctrine_Resource_Client::getInstance()->getConfig($key); } public function getParams() { if ($this->_params === null) { $this->_params = new Doctrine_Resource_Params(); } return $this->_params; } public function get($key) { return $this->getParams()->get($key); } public function set($key, $value) { return $this->getParams()->set($key, $value); } public function execute() { $url = $this->getConfig()->get('url'); $url .= strstr($this->getConfig()->get('url'), '?') ? '&':'?'; $url .= http_build_query($this->getParams()->getAll()); $response = file_get_contents($url); return $response; } public function hydrate(array $array, $model, $passedKey = null) { $config = $this->getConfig(); $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->set($key, $this->hydrate($value, $model, $config, $key)); } else { $r->set($key, $value); } } $collection[] = $r; } return $collection; } }