Skip to content

Commit

Permalink
Add compat with latest Cargo versions
Browse files Browse the repository at this point in the history
Fixes #781
  • Loading branch information
JeroenDeDauw committed Jul 9, 2024
1 parent 70d68bb commit a5b787a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Map/CargoFormat/CargoFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

use CargoDisplayFormat;
use Maps\MapsFactory;
use Parser;
use ParserOutput;

class CargoFormat extends CargoDisplayFormat {

/** @var Parser|null */
private $parserOutput;
/**
* @var $parser Parser|ParserOutput|null
*/
private $parser;

public function __construct( $output, $parserOutput = null ) {
parent::__construct( $output, $parserOutput );
$this->parserOutput = $parserOutput;
public function __construct( $output, $parser = null ) {
parent::__construct( $output, $parser );
$this->parser = $parser;
}

public static function allowedParameters() {
Expand All @@ -34,14 +38,22 @@ public function display( array $valuesTable, array $formattedValuesTable, array
$displayParams
);

if ( $this->parserOutput ) {
$this->parserOutput->addHeadItem( $mapOutput->getHeadItems() );
$this->parserOutput->addModules( $mapOutput->getResourceModules() );
if ( $this->parser !== null ) {
$this->getParserOutput()->addHeadItem( $mapOutput->getHeadItems() );
$this->getParserOutput()->addModules( $mapOutput->getResourceModules() );
}

return $mapOutput->getHtml();
}

private function getParserOutput(): ParserOutput {
if ( $this->parser instanceof Parser ) {
return $this->parser->getOutput();
}

return $this->parser;
}

private function getResultBuilder(): CargoOutputBuilder {
return MapsFactory::globalInstance()->newCargoOutputBuilder();
}
Expand Down

0 comments on commit a5b787a

Please sign in to comment.