Testing relation mapping

This commit is contained in:
Dennis Eichhorn 2015-12-22 18:13:24 +01:00
parent e3080fd299
commit 0e144f25da
2 changed files with 8 additions and 7 deletions

View File

@ -21,12 +21,13 @@ use phpOMS\DataStorage\Database\Query\Column;
class CollectionMapper extends MediaMapper class CollectionMapper extends MediaMapper
{ {
protected static $hasMany = [ protected static $hasMany = [
'source' => [ 'sources' => [
'mapper' => null, 'mapper' => '\Modules\Media\Models\MediaMapper', /* mapper of the related object */
'table' => 'media_relation', 'relationmapper' => null, /* if the relation itself is a more complex object that has it's own mapper */
'dst' => 'media_relation_dst', 'table' => 'media_relation', /* table of the related object, null if no relation table is used (many->1) */
'src' => 'media_relation_src' 'dst' => 'media_relation_dst',
] 'src' => 'media_relation_src',
],
]; ];
/** /**

View File

@ -34,7 +34,7 @@ class MediaMapper extends DataMapperAbstract
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'versioned'], 'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'versioned'],
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path'], 'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path'],
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'], 'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
'media_collection' => ['name' => 'media_collection', 'type' => 'int', 'internal' => 'collection'], 'media_collection' => ['name' => 'media_collection', 'type' => 'bool', 'internal' => 'collection'],
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'], 'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'], 'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'media_created_at' => ['name' => 'media_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], 'media_created_at' => ['name' => 'media_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],