public function mapValue(Reflection\Property $property, $value) { if ($property->hasOption(Reflection\Property::OPTION_ASSOC) && $property->getOption(Reflection\Property::OPTION_ASSOC) instanceof Association\ManyToOne && !empty($value)) { return $value[0]; } return $value; }
public function unmapValue(Entity\Reflection\Property $property, $value) { // Call map filter from property option if ($property->hasOption(Entity\Reflection\Property::OPTION_MAP_FILTER)) { $value = call_user_func($property->getOption(Entity\Reflection\Property::OPTION_MAP_FILTER)[1], $value); } if ($value instanceof Entity\Collection) { return $this->unmapCollection($value); } elseif ($value instanceof Entity) { return $this->unmapEntity($value); } // Call adapter's mapping if needed if (!$property->getEntityReflection()->hasAdapter()) { throw new Exception\InvalidArgumentException("Entity " . $property->getEntityReflection()->getClassName() . " has no adapter defined!"); } if (isset($this->adapterMappings[$property->getEntityReflection()->getAdapterName()])) { return $this->adapterMappings[$property->getEntityReflection()->getAdapterName()]->unmapValue($property, $value); } return $value; }