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

Use dependency injection #1

Open
mwjames opened this issue Feb 7, 2015 · 1 comment
Open

Use dependency injection #1

mwjames opened this issue Feb 7, 2015 · 1 comment
Assignees

Comments

@mwjames
Copy link

mwjames commented Feb 7, 2015

I would propose you split your SDImportData into smaller parts which would allow at a later point to import json without having the change the whole parser class.

    $csvDataReder = new CsvDataRender(); // Handling of csv specifc data
    $dataAnnotator = new DataAnnotator() // Create smw annotation

    $dataImportParserFunction = new DataImportParserFunction( $csvDataReder, $dataAnnotator );
    $dataImportParserFunction->parse( ... )

You can see [0] how to use injection in a parser function that splits responsibilities and make the code a bit easier to maintain and understood.

[0] https://github.com/SemanticMediaWiki/SemanticInterlanguageLinks/blob/master/src/ParserFunctionFactory.php#L26

@toniher toniher self-assigned this Feb 9, 2015
@toniher
Copy link
Owner

toniher commented Feb 9, 2015

Thanks, I'll try it.

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

No branches or pull requests

2 participants