Skip to content

Commit

Permalink
Fix post update listener
Browse files Browse the repository at this point in the history
  • Loading branch information
visa4 committed Jun 6, 2016
1 parent 2891b7f commit 2f43de9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
'page_size' => 10,
'page_size_param' => 'page_size',
'collection_class' => 'Zend\Paginator\Paginator',
'entity_class' => 'Strapieno\UserAvatar\Model\Entity\UserAvatarEntity',
'entity_class' => 'Strapieno\UserAvatar\Model\Entity\AvatarEntity',
]
],
'zf-content-negotiation' => [
Expand All @@ -98,7 +98,7 @@
'zf-hal' => [
// map each class (by name) to their metadata mappings
'metadata_map' => [
'Strapieno\UserAvatar\Model\Entity\UserAvatarEntity' => [
'Strapieno\UserAvatar\Model\Entity\AvatarEntity' => [
'entity_identifier_name' => 'id',
'route_name' => 'api-rest/user/avatar',
'route_identifier_name' => 'user_id',
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/UserRestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function onPostUpdate(ResourceEvent $e)
$id = $e->getParam('id');
$user = $this->getUserFromId($id);
$image = $e->getParam('image');

$image->setId($id);
if ($user instanceof AvatarAwareInterface && $user instanceof ActiveRecordInterface) {

$user->setAvatar($this->getUrlFromImage($image, $serviceLocator));
Expand Down
2 changes: 1 addition & 1 deletion tests/Listener/UserRestListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UserRestListenerTest extends \PHPUnit_Framework_TestCase
'user' => [
'type' => 'Segment',
'options' => [
'route' => '/user',
'route' => '/user[/:user_id]',
],
'child_routes' => [
'avatar' => [
Expand Down

0 comments on commit 2f43de9

Please sign in to comment.