ImportEngineBundle
ImportEngineBundle copied to clipboard
use as export
mathielen_import_engine:
storageprovider:
default:
type: doctrine
queries:
- AppBundle\Entity\Client
importers:
avantage_importer:
object_factory:
type: default
class: AppBundle\Entity\Client
target:
type: service
service: service_writer
method: writeItem
public function writeItem(Client $client)
{
var_dump($client);
Bobject(AppBundle\Entity\Client)#587
(4) {
["id":protected]=> NULL
["name":protected]=> NULL
["id"]=> string(0) "123"
["name"]=> string(0) "Anton"
if use:
$client->getName()
view:
NULL
rewrite:
object_factory:
# type: default
# class: AppBundle\Entity\Client
type: jms_serializer
class: AppBundle\Entity\Client
but jms_serializer not use
accessor:
getter: getFuu
Hi Avtonom, If you are using the 'default' serializer, your properties (id, name) must be public, as the serializer just writes to the properties, without doing any magic :) Using the jms-serializer is recommended though.
I dont know what you mean with the accessor/getter thing in your second example? Could you elaborate it a little more?
Regards Markus
@mathielen thank you for quick response! Configurator "getter" should call my method to get the value for the variable ( http://jmsyst.com/libs/serializer/master/reference/annotations#accessor )
Ok, I see. Well, the serializer is used to build the object from the underlying array. So there wont be any getter involved, only setters. See: https://github.com/mathielen/import-engine/blob/master/src/Mathielen/DataImport/Writer/ObjectWriter/JmsSerializerObjectFactory.php
Tell me, please, as it to solve two problems:
- get the value "Card" of the class ServiceWriter
public function getCard()
{
return $this->card->code();
}
- to get the value for the field type DateTime
/**
* @return \DateTime
*/
public function getDateCreated()
{
return $this->dateCreated;
}
/**
* @param \DateTime $dateCreated
*/
public function setDateCreated($dateCreated)
{
$this->dateCreated = $dateCreated;
}
var_dump:
["dateCreated":protected]=> NULL
["card":protected]=> NULL
problems 2 if type = default
object_factory:
type: default
to var_dump
["dateCreated":protected]=> NULL
["dateCreated"]=> object(DateTime)#614 (3) {
but I can not get this value
["dateCreated":protected]=> NULL ["dateCreated"]=> object(DateTime)#614 (3) {
solved by commenting the line "object_factory". But we get the array instead of an object. Because "Query::HYDRATE_ARRAY" in mathielen/import-engine/src/Mathielen/DataImport/Reader/DoctrineQueryReader.php:42
now we have to get Entity->relation->Entity->name =(
Dude, it seems like you just want to query doctrine and process the entities. You really should just use doctrine the old fashioned way :) The ImportEngineBundle is way more abstracted then you need to have. It is a wrapper around https://github.com/ddeboer/data-import, which is already very abstract. Only use the ImportEngineBundle if you have a lot of different import/export scenarios with different kind of sources and targets and complex validation and transformation requirements.
Yes, I understand what you write. I develop export and want to do it on the basis of this solution. But I do not have Reader flat Entities. I need to relation. I tried using \Mathielen\DataImport\Reader\ServiceReader use that to write doctrine the old fashioned, but I get Segmentation fault