DCOM-309: Design metadata API to map 0..N properties to 0..M values
- Dominant language
- PHP
- Stars
- 5.8k
- Forks
- 284
- PR merge metrics
- No merged PRs in 30d
Description
Jira issue originally created by user @ocramius:
We need a design for an API that allows converting (bi-directional) an arbitrary number of properties to an arbitrary number of values.
A rudimentary approach could be as following:
```
interface ToValueConverterInterface
{
// must be inlinable?
public function **invoke(
PropertiesMapInterface $properties // these are the properties in an object - not sure if we should pass in the object
) : ValuesMapInterface; // may be an array of scalars - not sure
}
interface ToObjectConverterInterface
{
// must be inlinable?
public function **invoke(
ValuesMapInterface $values // may be an array of scalars - not sure
) : PropertiesMapInterface; // these are the properties in an object - not sure if we should pass in the object
}
interface PropertiesMappingInterface
{
public function buildToValuesConverter(MapperContext $mapperCtx) : ToValueConverterInterface;
public function buildToObjectConverter(MapperContext $) : ToObjectConverterInterface;
}
```
`buildToValuesConverter` and `buildToObjectConverter` must be idempotent, so that we can generate code for each direction of the conversion via [DCOM-307](http://www.doctrine-project.org/jira/browse/DCOM-307) (Code inliner)
Contributor guide
Assessment
This issue has not been assessed yet.