Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/298' into develop
Browse files Browse the repository at this point in the history
Forward port #298
  • Loading branch information
michalbundyra committed Jan 17, 2018
2 parents bdef40e + 986c90e commit 6d983a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ All notable changes to this project will be documented in this file, in reverse
Doctrine Resource listener attached via config. These are now correctly
dispatched.

- [#298](https://github.com/zfcampus/zf-apigility-doctrine/pull/298) fixes
data passed to listener on patch method.

## 2.1.0 - 2016-10-17

### Added
Expand Down
7 changes: 6 additions & 1 deletion src/Server/Resource/DoctrineResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,15 @@ public function patch($id, $data)
$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_PRE, $entity, $data);
if ($results->last() instanceof ApiProblem) {
return $results->last();
} elseif (! $results->isEmpty() && $results->last() !== null) {
// TODO Change to a more logical/secure way to see if data was acted and and we have the expected response
$preEventData = $results->last();
} else {
$preEventData = $data;
}

// Hydrate entity with patched data
$this->getHydrator()->hydrate((array) $data, $entity);
$this->getHydrator()->hydrate((array) $preEventData, $entity);

$results = $this->triggerDoctrineEvent(DoctrineResourceEvent::EVENT_PATCH_POST, $entity, $data);
if ($results->last() instanceof ApiProblem) {
Expand Down

0 comments on commit 6d983a6

Please sign in to comment.