Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/PhlyRestfully/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,12 @@ protected function getIdentifier($routeMatch, $request)
{
$identifier = $this->getIdentifierName();
$id = $routeMatch->getParam($identifier, false);
if ($id) {
if ($id !== false) {
return $id;
}

$id = $request->getQuery()->get($identifier, false);
if ($id) {
if ($id !== false) {
return $id;
}

Expand Down
14 changes: 14 additions & 0 deletions test/PhlyRestfullyTest/ResourceControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,20 @@ public function testUsesConfiguredIdentifierNameToGetIdentifier()
$result = $getIdentifier->invoke($this->controller, $routeMatch, $request);
$this->assertEquals('bar', $result);
}

public function testIdentifierMatchedAgainstParameter()
{
$r = new ReflectionObject($this->controller);
$getIdentifier = $r->getMethod('getIdentifier');
$getIdentifier->setAccessible(true);

$routeMatch = $this->event->getRouteMatch();
$request = $this->controller->getRequest();

$routeMatch->setParam('id', '0');
$result = $getIdentifier->invoke($this->controller, $routeMatch, $request);
$this->assertEquals('0', $result);
}

/**
* @group 44
Expand Down