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/100' into develop
Browse files Browse the repository at this point in the history
Forward port #100
  • Loading branch information
weierophinney committed Jul 8, 2015
2 parents 8b11ccf + 999ca3f commit 14b542a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Plugin/Hal.php
Expand Up @@ -632,11 +632,18 @@ public function renderEntity(Entity $halEntity, $renderEntity = true, $depth = 0
$halEntity->setLinks($entityLinks);
$entity['_links'] = $this->fromResource($halEntity);

$payload = new ArrayObject($entity);
$this->getEventManager()->trigger(
__FUNCTION__ . '.post',
$this,
array('payload' => $payload, 'entity' => $halEntity)
);

if (isset($entityHash)) {
unset($this->entityHashStack[$entityHash]);
}

return $entity;
return $payload->getArrayCopy();
}

/**
Expand Down
17 changes: 17 additions & 0 deletions test/Plugin/HalTest.php
Expand Up @@ -2313,4 +2313,21 @@ public function testAllowsSpecifyingAlternateCallbackForReturningEntityId()
$this->assertEquals('bar', $item['foo']);
}
}

/**
* @group 100
*/
public function testRenderEntityPostEventIsTriggered()
{
$entity = array('id' => 1, 'foo' => 'bar');
$halEntity = new Entity($entity, 1);

$triggered = false;
$this->plugin->getEventManager()->attach('renderEntity.post', function ($e) use (&$triggered) {
$triggered = true;
});

$this->plugin->renderEntity($halEntity);
$this->assertTrue($triggered);
}
}

0 comments on commit 14b542a

Please sign in to comment.