ProfessionalWiki /
ModernTimeline
| 1 | <?php |
||
| 2 | |||
| 3 | declare( strict_types = 1 ); |
||
| 4 | |||
| 5 | namespace ModernTimeline; |
||
| 6 | |||
| 7 | use ModernTimeline\ResultFacade\ResultFormat; |
||
| 8 | use ModernTimeline\ResultFacade\ResultSimplifier; |
||
| 9 | use ModernTimeline\ResultFacade\ResultFormatRegistry; |
||
| 10 | use ModernTimeline\ResultFacade\SimpleQueryResult; |
||
| 11 | use ModernTimeline\ResultFacade\SubjectCollection; |
||
| 12 | use ParamProcessor\Param; |
||
| 13 | use ParamProcessor\ProcessedParam; |
||
| 14 | use ParamProcessor\ProcessingResult; |
||
| 15 | use SMW\Parser\RecursiveTextProcessor; |
||
| 16 | use SMW\Query\QueryResult; |
||
|
0 ignored issues
–
show
|
|||
| 17 | use SMW\Query\ResultPrinter; |
||
| 18 | use SMWQuery; |
||
| 19 | |||
| 20 | class ModernTimelinePrinter implements ResultPrinter { |
||
| 21 | |||
| 22 | private ResultFormat $format; |
||
| 23 | |||
| 24 | public function __construct() { |
||
| 25 | $registry = new ResultFormatRegistry(); |
||
| 26 | |||
| 27 | 5 | $registry->newFormat() |
|
| 28 | 5 | ->withName( 'moderntimeline' ) |
|
| 29 | ->andMessageKey( 'modern-timeline-format-name' ) |
||
| 30 | 5 | ->andParameterDefinitions( TimelineOptions::getTimelineParameterDefinitions() ) |
|
| 31 | 5 | ->andPresenterBuilder( function() { |
|
| 32 | 5 | return new TimelinePresenter(); |
|
| 33 | 5 | } ) |
|
| 34 | 5 | ->register(); |
|
| 35 | 4 | ||
| 36 | 5 | $this->format = $registry->getFormatByName( 'moderntimeline' ); |
|
| 37 | 5 | } |
|
| 38 | |||
| 39 | 5 | public function getName(): string { |
|
| 40 | 5 | return wfMessage( $this->format->getNameMessageKey() )->text(); |
|
| 41 | } |
||
| 42 | |||
| 43 | public function getParamDefinitions( array $definitions ) { |
||
| 44 | return array_merge( $definitions, $this->format->getParameterDefinitions() ); |
||
| 45 | } |
||
| 46 | 5 | ||
| 47 | 5 | /** |
|
| 48 | * @param QueryResult $result |
||
| 49 | * @param Param[] $parameters |
||
| 50 | * @param int $outputMode |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getResult( QueryResult $result, array $parameters, $outputMode ): string { |
||
| 55 | return $this->format->buildPresenter()->presentResult( |
||
| 56 | new SimpleQueryResult( |
||
| 57 | 4 | $this->simplifyResult( $result ), |
|
| 58 | 4 | $this->newProcessingResultFromParams( $parameters ) |
|
| 59 | 4 | ) |
|
| 60 | 4 | ); |
|
| 61 | 4 | } |
|
| 62 | |||
| 63 | private function simplifyResult( QueryResult $result ): SubjectCollection { |
||
| 64 | return ( new ResultSimplifier() )->newSubjectCollection( $result ); |
||
| 65 | } |
||
| 66 | 4 | ||
| 67 | 4 | /** |
|
| 68 | * This is code copied over from ParamProcessor to go from the deprecated Param[] to ProcessingResult. |
||
| 69 | * Once the main ResultPrinter interface has been migrated away from Param this can be removed. |
||
| 70 | */ |
||
| 71 | private function newProcessingResultFromParams( array $params ): ProcessingResult { |
||
| 72 | $parameters = []; |
||
| 73 | |||
| 74 | 4 | foreach ( $params as $param ) { |
|
| 75 | 4 | $processedParam = new ProcessedParam( |
|
| 76 | $param->getName(), |
||
| 77 | 4 | $param->getValue(), |
|
| 78 | 4 | $param->wasSetToDefault() |
|
| 79 | 4 | ); |
|
| 80 | 4 | ||
| 81 | 4 | if ( !$param->wasSetToDefault() ) { |
|
| 82 | $processedParam->setOriginalName( $param->getOriginalName() ); |
||
| 83 | $processedParam->setOriginalValue( $param->getOriginalValue() ); |
||
| 84 | 4 | } |
|
| 85 | 4 | ||
| 86 | 4 | $parameters[$processedParam->getName()] = $processedParam; |
|
| 87 | } |
||
| 88 | |||
| 89 | 4 | return new ProcessingResult( |
|
| 90 | $parameters, |
||
| 91 | [] |
||
| 92 | 4 | ); |
|
| 93 | 4 | } |
|
| 94 | 4 | ||
| 95 | public function getQueryMode( $context ): int { |
||
| 96 | return SMWQuery::MODE_INSTANCES; |
||
| 97 | } |
||
| 98 | 4 | ||
| 99 | 4 | public function setShowErrors( $show ): void { |
|
| 100 | } |
||
| 101 | |||
| 102 | public function isExportFormat(): bool { |
||
| 103 | return false; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function getDefaultSort(): string { |
||
| 107 | return 'ASC'; |
||
| 108 | } |
||
| 109 | 4 | ||
| 110 | 4 | public function isDeferrable(): bool { |
|
| 111 | return false; |
||
| 112 | } |
||
| 113 | 4 | ||
| 114 | 4 | public function supportsRecursiveAnnotation(): bool { |
|
| 115 | return false; |
||
| 116 | } |
||
| 117 | 1 | ||
| 118 | 1 | public function setRecursiveTextProcessor( RecursiveTextProcessor $recursiveTextProcessor ): void { |
|
| 119 | } |
||
| 120 | } |
||
| 121 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths