Add Data transformers for download - #10
Open
azathcat wants to merge 1 commit into
Open
Conversation
csrui
suggested changes
Feb 1, 2021
Comment on lines
+103
to
+105
| if ( class_exists( $transformer_class ) ) { | ||
| $transfomer = new $transformer_class(); | ||
| return $transfomer->transform( $data, $config ); |
Contributor
There was a problem hiding this comment.
O $transformer_class que tens agora poderá ser a base, mas seria bom poder receber uma classe de fora para ser mais extensível. Futuro pull request ;)
O resto da lógica para remover complexidade e aumentar o que é testado.
Suggested change
| if ( class_exists( $transformer_class ) ) { | |
| $transfomer = new $transformer_class(); | |
| return $transfomer->transform( $data, $config ); | |
| if ( ! class_exists( $transformer_class ) ) { | |
| return $data; | |
| } | |
| $transfomer = new $transformer_class(); | |
| if ( ! $transformer instanceof Transformer ) { | |
| return $data; | |
| } | |
| return $transfomer->transform( $data, $config ); |
xipasduarte
reviewed
Mar 12, 2021
| JSON_PRETTY_PRINT | ||
| ); | ||
| private function apply_transformer( $data, Project $config ) { | ||
| //TODO: receive outside classes. |
Member
There was a problem hiding this comment.
This doesn't actually make sense in this way. What we'll have is a string with the class name for the transformer in the config file. So it'll not come as an argument, but will work mostly as is here.
It's more like this (just a rough example):
$transformer_class = $config->get_tranformer() ? $config->get_tranformer() : __NAMESPACE__ . '\\Transformers\\' . ucfirst( $config->get_format() );
xipasduarte
approved these changes
Mar 12, 2021
Collaborator
Author
|
Reminder: careful with the change made in #36 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add transformers for specific formats. Here we add just for jed.
closes #2