Last active
June 15, 2017 21:01
-
-
Save mneuhaus/ffb4373560d2c11ba5280aa18d5c4324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ProductMapping extends AbstractMapping { | |
/** | |
* Type/Name of the coremedia content | |
* | |
* @var string | |
*/ | |
protected $sourceType = 'pim_product'; | |
/** | |
* ClassName of the Entity a Coremedia Items gets mapped to | |
* | |
* @var string | |
*/ | |
protected $targetEntity = '\My\Namespace\Domain\Model\Product'; | |
/** | |
* Fields to be mapped to the target entity | |
* | |
* @var array | |
*/ | |
protected $fields = [ | |
'name' => [ | |
'property' => 'name' | |
], | |
'creationDate' => [ | |
'property' => 'crdate', | |
'converter' => 'dateToTimestamp' | |
] | |
]; | |
public function dateToTimestamp($date, $field) { | |
... convert $date into a timestamp and return the value | |
} | |
} | |
class ArticleMapping extends AbstractMapping { | |
/** | |
* Type/Name of the coremedia content | |
* | |
* @var string | |
*/ | |
protected $sourceType = 'pim_article'; | |
/** | |
* ClassName of the Entity a Coremedia items gets mapped to | |
* | |
* @var string | |
*/ | |
protected $targetEntity = '\My\Namespace\Domain\Model\Article'; | |
/** | |
* Fields to be mapped to the target entity | |
* | |
* @var array | |
*/ | |
protected $fields = [ | |
'name' => [ | |
'property' => 'name' | |
], | |
'product' => [ | |
'property' => 'product', | |
'converter' => 'oneToMany', | |
'targetEntity' => '\My\Namespace\Domain\Model\Product' | |
] | |
]; | |
public function oneToMany($product, $field) { | |
... resolve relation to targetEntity ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment