11d94f4f4SAndreas Gohr<?php 21d94f4f4SAndreas Gohr 31d94f4f4SAndreas Gohrnamespace dokuwiki\plugin\extension; 41d94f4f4SAndreas Gohr 51d94f4f4SAndreas Gohruse dokuwiki\Remote\Response\ApiResponse; 61d94f4f4SAndreas Gohr 71d94f4f4SAndreas Gohrclass ExtensionApiResponse extends ApiResponse 81d94f4f4SAndreas Gohr{ 91d94f4f4SAndreas Gohr protected Extension $extension; 101d94f4f4SAndreas Gohr 111d94f4f4SAndreas Gohr /** @var string The type of this extension ("plugin" or "template") */ 121d94f4f4SAndreas Gohr public $type; 131d94f4f4SAndreas Gohr 141d94f4f4SAndreas Gohr /** @var string The id of this extension (templates are prefixed with "template") */ 151d94f4f4SAndreas Gohr public $id; 161d94f4f4SAndreas Gohr 171d94f4f4SAndreas Gohr /** @var string The base name of this extension */ 181d94f4f4SAndreas Gohr public $base; 191d94f4f4SAndreas Gohr 201d94f4f4SAndreas Gohr /** @var string The display name of this extension */ 211d94f4f4SAndreas Gohr public $name; 221d94f4f4SAndreas Gohr 231d94f4f4SAndreas Gohr /** @var string The installed version/date of this extension */ 241d94f4f4SAndreas Gohr public $version; 251d94f4f4SAndreas Gohr 261d94f4f4SAndreas Gohr /** @var string The author of this extension */ 271d94f4f4SAndreas Gohr public $author; 281d94f4f4SAndreas Gohr 291d94f4f4SAndreas Gohr /** @var string The description of this extension */ 301d94f4f4SAndreas Gohr public $description; 311d94f4f4SAndreas Gohr 321d94f4f4SAndreas Gohr /** @var bool Whether this extension is installed */ 331d94f4f4SAndreas Gohr public $isInstalled; 341d94f4f4SAndreas Gohr 351d94f4f4SAndreas Gohr /** @var bool Whether this extension is enabled */ 361d94f4f4SAndreas Gohr public $isEnabled; 371d94f4f4SAndreas Gohr 381d94f4f4SAndreas Gohr /** @var bool Whether an update is available */ 391d94f4f4SAndreas Gohr public $updateAvailable; 401d94f4f4SAndreas Gohr 411d94f4f4SAndreas Gohr /** @var bool Whether this extension is bundled with DokuWiki */ 421d94f4f4SAndreas Gohr public $isBundled; 431d94f4f4SAndreas Gohr 441d94f4f4SAndreas Gohr /** @var bool Whether this extension is under git control */ 451d94f4f4SAndreas Gohr public $isGitControlled; 461d94f4f4SAndreas Gohr 471d94f4f4SAndreas Gohr /** @var string[] Notices for this extension */ 481d94f4f4SAndreas Gohr public $notices; 491d94f4f4SAndreas Gohr 501d94f4f4SAndreas Gohr /** @var string Documentation URL for this extension */ 511d94f4f4SAndreas Gohr public $url; 521d94f4f4SAndreas Gohr 531d94f4f4SAndreas Gohr /** @var string[] The component types this plugin provides */ 541d94f4f4SAndreas Gohr public $componentTypes; 551d94f4f4SAndreas Gohr 561d94f4f4SAndreas Gohr /** @var string The last available remote update date */ 571d94f4f4SAndreas Gohr public $lastUpdate; 581d94f4f4SAndreas Gohr 591d94f4f4SAndreas Gohr /** @var string The download URL for this extension */ 601d94f4f4SAndreas Gohr public string $downloadURL; 611d94f4f4SAndreas Gohr 621d94f4f4SAndreas Gohr /** 631d94f4f4SAndreas Gohr * Constructor 641d94f4f4SAndreas Gohr * 651d94f4f4SAndreas Gohr * @param Extension $extension The extension to create the response for 661d94f4f4SAndreas Gohr */ 671d94f4f4SAndreas Gohr public function __construct(Extension $extension) 681d94f4f4SAndreas Gohr { 691d94f4f4SAndreas Gohr $this->extension = $extension; 701d94f4f4SAndreas Gohr $this->type = $extension->getType(); 711d94f4f4SAndreas Gohr $this->id = $extension->getId(); 721d94f4f4SAndreas Gohr $this->base = $extension->getBase(); 731d94f4f4SAndreas Gohr $this->name = $extension->getDisplayName(); 741d94f4f4SAndreas Gohr $this->version = $extension->getInstalledVersion(); 751d94f4f4SAndreas Gohr $this->author = $extension->getAuthor(); 761d94f4f4SAndreas Gohr $this->description = $extension->getDescription(); 771d94f4f4SAndreas Gohr $this->isInstalled = $extension->isInstalled(); 781d94f4f4SAndreas Gohr $this->isEnabled = $extension->isEnabled(); 791d94f4f4SAndreas Gohr $this->updateAvailable = $extension->isUpdateAvailable(); 801d94f4f4SAndreas Gohr $this->isBundled = $extension->isBundled(); 811d94f4f4SAndreas Gohr $this->isGitControlled = $extension->isGitControlled(); 821d94f4f4SAndreas Gohr $this->componentTypes = $extension->getComponentTypes(); 831d94f4f4SAndreas Gohr $this->lastUpdate = $extension->getLastUpdate(); 841d94f4f4SAndreas Gohr $this->url = $extension->getURL(); 851d94f4f4SAndreas Gohr $this->downloadURL = $extension->getDownloadURL(); 861d94f4f4SAndreas Gohr 871d94f4f4SAndreas Gohr // Add notices 881d94f4f4SAndreas Gohr $this->notices = array_merge(...array_values(Notice::list($extension))); 891d94f4f4SAndreas Gohr } 901d94f4f4SAndreas Gohr 911d94f4f4SAndreas Gohr /** @inheritdoc */ 92*093fe67eSAndreas Gohr public function __toString(): string 931d94f4f4SAndreas Gohr { 941d94f4f4SAndreas Gohr return $this->extension->getId(); 951d94f4f4SAndreas Gohr } 961d94f4f4SAndreas Gohr} 97