Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MappingItemConverter #266

Closed
Nexotap opened this issue Sep 24, 2015 · 6 comments
Closed

MappingItemConverter #266

Nexotap opened this issue Sep 24, 2015 · 6 comments

Comments

@Nexotap
Copy link

Nexotap commented Sep 24, 2015

I posted the same in data-import-bundle. But that bundle looks quite abandoned. So here it again.

I'm trying to use MappingItemConverter. But I cant find it somewhere in the source. Can someone enlighten me, please?

@Baachi
Copy link
Collaborator

Baachi commented Sep 24, 2015

Hey!

What do you mean exactly? The class is here.
In the actual master branch it was refactored and now it is a simple step.

If you give some more information, maybe i can help :-)

@Nexotap
Copy link
Author

Nexotap commented Sep 25, 2015

I'm sorry about my ignorance of this. Since I'm using Symfony, what I'm doing most of the time, is using symfony-bundles with composer. I'm not too aware of all this stuff. It seems, the bundle is not fetching the actual master branch.

Is there any need of that symfony bundle at all? Or is it easily possible without?
Maybe you can give me a short example of how I would do this?

Thank you in advance :)

@Baachi
Copy link
Collaborator

Baachi commented Sep 26, 2015

Hey, yes the bundle is currently not compatible with the current master branch. But there are good new for you, you don't need the bundle.
Here is a short script:

$reader = new Reader\DbalReader($conn, 'SELECT * FROM users');
$writer = new Writer\CsvWriter(';', '"', fopen(__DIR__.'/test.csv', 'a+'));

$mapping = new Step\MappingStep();
$mapping->map('first_name', 'firstname');
$mapping->map('last_name', 'lastname');

$filter = new Step\FilterStep();
$filter->add(function($) { return $v['lastname'] !== 'Admin'; });

$workflow = new new Workflow\StepAggregator($reader);
$workflow->addStep($mapping);
$workflow->addStep($filter);
$workflow->addWriter($writer);

$workflow->process();

@Nexotap
Copy link
Author

Nexotap commented Sep 28, 2015

Thank you very much. Got it working now. There's one thing which is not clear to me. Why do I have to write the mapping with brackets like this:

$mapping->map('[first_name]', '[firstname]');

Would it not be sufficient to ommit the brackets, like you showed me in the code above?

Another thing which concerns me. Do you consider working with the master branch safe or should I stick with the stable? Alltough there's no Step there yet.

@Baachi
Copy link
Collaborator

Baachi commented Sep 28, 2015

@Nexotap This by design, sorry i missed that 😢 .
We rely on the property-accessor component from symfony, and they use this convention.

To you second question: Generally i doesn't recommend to rely on the master branch, because if we change something on the core, your app will break.
You should always use a stable version, to ensure that your app will work with this branch.

@Nexotap
Copy link
Author

Nexotap commented Sep 30, 2015

@Baachi Don't worry, you are forgiven 😏. I'll still use the master branch, since I like Step stuff.

Anyway, thank you alot for the help and who knows, maybe the time comes I can help out in one other another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants