Skip to content

Commit

Permalink
adding code to pass header as prameter for the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
teresko committed Feb 22, 2016
1 parent 4bb4139 commit 4ebe117
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Fracture/Http/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,24 @@ protected function applyContentParsers($instance)

foreach ($this->parsers as $value => $parser) {
if ($header->contains($value)) {
$parameters = $this->alterParameters($parameters, $parser, $value);
$parameters += $this->alterParameters($parser, $value, $header);
}
}

$instance->setParameters($parameters, true);
}


private function alterParameters($parameters, $parser, $value)
private function alterParameters($parser, $value, $header)
{
$result = call_user_func($parser);
$result = call_user_func($parser, $header);

if (false === is_array($result)) {
$message = "Parser for '$value' did not return a 'name => value' array of parameters";
trigger_error($message, \E_USER_WARNING);
}

$parameters += $result;
return $parameters;
return $result;
}


Expand Down

0 comments on commit 4ebe117

Please sign in to comment.