drahak / Restful

Drahak\Restful - Nette REST API bundle
0 stars 0 forks source link

providing NullMapper also for NULL value #94

Closed kuzmamar closed 8 years ago

kuzmamar commented 8 years ago

This should fix problem #93

Stene3 commented 8 years ago

I think your NULL_Value definition could completely replace the current 'NULL' (quoted) one - it's not working and you'll never get the current NullMapper:

$mappers = [
    'NULL' => 'NullMapper',
    'application/json' => 'JsonMapper',
];

$contentType = explode(';', NULL); // content-type header not set in the request
$contentType = Strings::trim($contentType[0]);

isset($mappers[$contentType]) === FALSE // always FALSE in the current version

but your definition works:

$mappers = [
    NULL => 'NullMapper',
    'application/json' => 'JsonMapper',
];

$contentType = explode(';', NULL); // content-type header not set in the request
$contentType = Strings::trim($contentType[0]);

isset($mappers[$contentType]) === TRUE // NULL is converted to the empty string and it fits to NULL key.
kuzmamar commented 8 years ago

@Stene3 You are probably right. I added the new constant, because i did not want to brake anything. :D But now i replaced. Let's @drahak to deside.