Skip to content

Commit

Permalink
Mark getObjectFieldName() public, merge in default opts
Browse files Browse the repository at this point in the history
Sometimes we need more granularity over field mapping,
e.g. providing a “context” array to a Folder->canCreate() method
Rather than calling setValue() on a new Folder instance.
  • Loading branch information
chillu committed Dec 20, 2016
1 parent 1bc0a65 commit 8cd7884
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Util/CaseInsensitiveFieldAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,16 @@ public function setValue(ViewableData $object, $fieldName, $value, $opts = [])
* Example: [ViewableDataCaseInsensitiveFieldMapper::HAS_METHOD => true]
* @return null|string Name in actual casing on $object
*/
protected function getObjectFieldName(ViewableData $object, $fieldName, $opts = [])
public function getObjectFieldName(ViewableData $object, $fieldName, $opts = [])
{
$opts = $opts ?: [];
$opts = array_merge([
self::HAS_METHOD => true,
self::HAS_FIELD => true,
self::HAS_SETTER => true,
self::DATAOBJECT => true,
], $opts);

$optFn = function ($type) use (&$opts) {
return (in_array($type, $opts) && $opts[$type] === true);
};
Expand Down

0 comments on commit 8cd7884

Please sign in to comment.