Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created November 7, 2017 19:25
Show Gist options
  • Select an option

  • Save adatta02/7769087bb94dfdf5e98b2cc30758a52a to your computer and use it in GitHub Desktop.

Select an option

Save adatta02/7769087bb94dfdf5e98b2cc30758a52a to your computer and use it in GitHub Desktop.
$formMapper->get("menuVisibility")
->addModelTransformer(new CallbackTransformer(
function ($bitmarkToList) {
$options = [0b1, 0b10, 0b100];
for($i = 0; $i < count($options); $i++){
$options[$i] = $options[$i] & $bitmarkToList;
}
return $options;
},
function ($listToBitMask) {
$res = array_pop($listToBitMask);
foreach($listToBitMask as $l){
$res = $res | $l;
}
return $res;
}
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment