public function toData($entity)
{
$result = parent::toData($entity);
$converterRules = $this->getRules();
if (!empty($converterRules[static::RULE_TYPE_SETTINGS])) {
$collection = $this->getSettingsCollection($entity);
foreach ($converterRules[static::RULE_TYPE_SETTINGS] as $key => $property) {
//Some properties only for writing we can't include them in the response
if ($property[0] == '!') {
continue;
}
//This is necessary when result data key does not match the property name of the entity
$key = is_int($key) ? $property : $key;
$result->{$property} = $collection[$key];
}
}
return $result;
}