Skip to content

Use dependency injection #1

@mwjames

Description

@mwjames

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions