ProfessionalWiki /
ModernTimeline
| 1 | <?php |
||
| 2 | |||
| 3 | declare( strict_types = 1 ); |
||
| 4 | |||
| 5 | namespace ModernTimeline; |
||
| 6 | |||
| 7 | use ModernTimeline\ResultFacade\SubjectCollection; |
||
| 8 | use ModernTimeline\SlidePresenter\SlidePresenter; |
||
| 9 | use SMWDITime; |
||
|
0 ignored issues
–
show
|
|||
| 10 | use MediaWiki\Title\Title; |
||
|
0 ignored issues
–
show
The type
MediaWiki\Title\Title was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 11 | use MediaWiki\Html\Html; |
||
|
0 ignored issues
–
show
The type
MediaWiki\Html\Html was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | |||
| 13 | class JsonBuilder { |
||
| 14 | |||
| 15 | 9 | public function __construct( |
|
| 16 | 9 | private SlidePresenter $slidePresenter |
|
| 17 | 9 | ) { |
|
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param Event[] $events |
||
| 22 | * @return array |
||
| 23 | 9 | */ |
|
| 24 | 9 | public function eventsToTimelineJson( array $events ): array { |
|
| 25 | $jsonEvents = []; |
||
| 26 | 9 | ||
| 27 | 8 | foreach ( $events as $event ) { |
|
| 28 | if ( $event->getSubject()->getWikiPage()->getTitle() !== null ) { |
||
| 29 | $jsonEvents[] = $this->buildEvent( $event ); |
||
| 30 | 9 | } |
|
| 31 | } |
||
| 32 | |||
| 33 | 8 | return [ 'events' => $jsonEvents ]; |
|
| 34 | } |
||
| 35 | |||
| 36 | 8 | public function buildEvent( Event $event ): array { |
|
| 37 | 8 | $jsonEvent = [ |
|
| 38 | 'text' => [ |
||
| 39 | 8 | 'headline' => $this->newHeadline( $event->getSubject()->getWikiPage()->getTitle() ), |
|
| 40 | 'text' => $this->slidePresenter->getText( $event->getSubject() ) |
||
| 41 | ], |
||
| 42 | 8 | 'start_date' => $this->timeToJson( $event->getStartDate() ), |
|
| 43 | 6 | ]; |
|
| 44 | |||
| 45 | if ( $event->getEndDate() !== null ) { |
||
| 46 | 8 | $jsonEvent['end_date'] = $this->timeToJson( $event->getEndDate() ); |
|
| 47 | } |
||
| 48 | |||
| 49 | if ( $event->hasImage() ) { |
||
| 50 | $jsonEvent['media'] = [ |
||
| 51 | 'url' => $event->getImageUrl(), |
||
| 52 | 'thumbnail' => $event->getImageUrl() |
||
| 53 | 8 | ]; |
|
| 54 | } |
||
| 55 | |||
| 56 | 8 | return $jsonEvent; |
|
| 57 | 8 | } |
|
| 58 | 8 | ||
| 59 | 8 | private function newHeadline( Title $title ): string { |
|
| 60 | 8 | return Html::element( |
|
| 61 | 'a', |
||
| 62 | [ 'href' => $title->getFullURL() ], |
||
| 63 | $title->getText() |
||
| 64 | ); |
||
| 65 | |||
| 66 | 8 | // return DataValueFactory::getInstance()->newDataValueByItem( $subject->getWikiPage() )->getLongHTMLText( smwfGetLinker() ); |
|
| 67 | } |
||
| 68 | 8 | ||
| 69 | 8 | private function timeToJson( SMWDITime $time ): array { |
|
| 70 | 8 | return [ |
|
| 71 | 8 | 'year' => $time->getYear(), |
|
| 72 | 8 | 'month' => $time->getMonth(), |
|
| 73 | 8 | 'day' => $time->getDay(), |
|
| 74 | 'hour' => $time->getHour(), |
||
| 75 | 'minute' => $time->getMinute(), |
||
| 76 | 'second' => (int)$time->getSecond(), |
||
| 77 | ]; |
||
| 78 | } |
||
| 79 | |||
| 80 | } |
||
| 81 |
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