Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added more flexibility to setting entity values

  • Loading branch information...
commit 78c1849eff1d23c7677034bf058ba78f423b60e8 1 parent 20b1da5
@jwage jwage authored
View
13 lib/Doctrine/REST/Client/EntityConfiguration.php
@@ -39,6 +39,7 @@ class EntityConfiguration
private $_prototype;
private $_reflection;
private $_reflectionProperties = array();
+ private $_properties = array();
private $_attributes = array(
'class' => null,
@@ -85,12 +86,20 @@ public function getProperties()
public function setValue($entity, $field, $value)
{
- $this->_reflectionProperties[$field]->setValue($entity, $value);
+ if (isset($this->_reflectionProperties[$field])) {
+ $this->_reflectionProperties[$field]->setValue($entity, $value);
+ } else {
+ $entity->$field = $value;
+ }
}
public function getValue($entity, $field)
{
- return $this->_reflectionProperties[$field]->getValue($entity);
+ if (isset($this->_reflectionProperties[$field])) {
+ return $this->_reflectionProperties[$field]->getValue($entity);
+ } else {
+ return isset($entity->$field) ? $entity->$field : null;
+ }
}
public function generateUrl(array $options)
View
7 lib/Doctrine/REST/Client/Manager.php
@@ -148,12 +148,7 @@ public function execute($entity, $url = null, $method = Client::GET, $parameters
private function _hydrate($configuration, $instance, $data)
{
foreach ($data as $key => $value) {
- if (is_array($value))
- {
- $configuration->setValue($instance, $key, (string) $value);
- } else {
- $configuration->setValue($instance, $key, $value);
- }
+ $configuration->setValue($instance, $key, $value);
}
return $instance;
Please sign in to comment.
Something went wrong with that request. Please try again.