Skip to content

Commit

Permalink
Moved readOnly check to GraphNavigator
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Mar 8, 2012
1 parent 33568ff commit c4bdee4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions Serializer/GenericDeserializationVisitor.php
Expand Up @@ -173,10 +173,6 @@ public function visitProperty(PropertyMetadata $metadata, $data)
return;
}

if ($metadata->readOnly) {
return;
}

if (!$metadata->type) {
throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->getDeclaringClass()->getName(), $metadata->name));
}
Expand Down
4 changes: 4 additions & 0 deletions Serializer/GraphNavigator.php
Expand Up @@ -114,6 +114,10 @@ public function accept($data, $type, VisitorInterface $visitor)
continue;
}

if (self::DIRECTION_DESERIALIZATION === $this->direction && $propertyMetadata->readOnly) {
continue;
}

// try custom handler
if (!$visitor->visitPropertyUsingCustomHandler($propertyMetadata, $data)) {
$visitor->visitProperty($propertyMetadata, $data);
Expand Down
6 changes: 1 addition & 5 deletions Serializer/XmlDeserializationVisitor.php
Expand Up @@ -196,11 +196,7 @@ public function startVisitingObject(ClassMetadata $metadata, $data, $type)
public function visitProperty(PropertyMetadata $metadata, $data)
{
$name = $this->namingStrategy->translateName($metadata);

if ($metadata->readOnly) {
return;
}


if (!$metadata->type) {
throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->getDeclaringClass()->getName(), $metadata->name));
}
Expand Down

0 comments on commit c4bdee4

Please sign in to comment.