1*1d94f4f4SAndreas Gohr<?php 2*1d94f4f4SAndreas Gohr 3*1d94f4f4SAndreas Gohrnamespace dokuwiki\plugin\extension; 4*1d94f4f4SAndreas Gohr 5*1d94f4f4SAndreas Gohruse dokuwiki\Remote\Response\ApiResponse; 6*1d94f4f4SAndreas Gohr 7*1d94f4f4SAndreas Gohrclass ExtensionApiResponse extends ApiResponse 8*1d94f4f4SAndreas Gohr{ 9*1d94f4f4SAndreas Gohr protected Extension $extension; 10*1d94f4f4SAndreas Gohr 11*1d94f4f4SAndreas Gohr /** @var string The type of this extension ("plugin" or "template") */ 12*1d94f4f4SAndreas Gohr public $type; 13*1d94f4f4SAndreas Gohr 14*1d94f4f4SAndreas Gohr /** @var string The id of this extension (templates are prefixed with "template") */ 15*1d94f4f4SAndreas Gohr public $id; 16*1d94f4f4SAndreas Gohr 17*1d94f4f4SAndreas Gohr /** @var string The base name of this extension */ 18*1d94f4f4SAndreas Gohr public $base; 19*1d94f4f4SAndreas Gohr 20*1d94f4f4SAndreas Gohr /** @var string The display name of this extension */ 21*1d94f4f4SAndreas Gohr public $name; 22*1d94f4f4SAndreas Gohr 23*1d94f4f4SAndreas Gohr /** @var string The installed version/date of this extension */ 24*1d94f4f4SAndreas Gohr public $version; 25*1d94f4f4SAndreas Gohr 26*1d94f4f4SAndreas Gohr /** @var string The author of this extension */ 27*1d94f4f4SAndreas Gohr public $author; 28*1d94f4f4SAndreas Gohr 29*1d94f4f4SAndreas Gohr /** @var string The description of this extension */ 30*1d94f4f4SAndreas Gohr public $description; 31*1d94f4f4SAndreas Gohr 32*1d94f4f4SAndreas Gohr /** @var bool Whether this extension is installed */ 33*1d94f4f4SAndreas Gohr public $isInstalled; 34*1d94f4f4SAndreas Gohr 35*1d94f4f4SAndreas Gohr /** @var bool Whether this extension is enabled */ 36*1d94f4f4SAndreas Gohr public $isEnabled; 37*1d94f4f4SAndreas Gohr 38*1d94f4f4SAndreas Gohr /** @var bool Whether an update is available */ 39*1d94f4f4SAndreas Gohr public $updateAvailable; 40*1d94f4f4SAndreas Gohr 41*1d94f4f4SAndreas Gohr /** @var bool Whether this extension is bundled with DokuWiki */ 42*1d94f4f4SAndreas Gohr public $isBundled; 43*1d94f4f4SAndreas Gohr 44*1d94f4f4SAndreas Gohr /** @var bool Whether this extension is under git control */ 45*1d94f4f4SAndreas Gohr public $isGitControlled; 46*1d94f4f4SAndreas Gohr 47*1d94f4f4SAndreas Gohr /** @var string[] Notices for this extension */ 48*1d94f4f4SAndreas Gohr public $notices; 49*1d94f4f4SAndreas Gohr 50*1d94f4f4SAndreas Gohr /** @var string Documentation URL for this extension */ 51*1d94f4f4SAndreas Gohr public $url; 52*1d94f4f4SAndreas Gohr 53*1d94f4f4SAndreas Gohr /** @var string[] The component types this plugin provides */ 54*1d94f4f4SAndreas Gohr public $componentTypes; 55*1d94f4f4SAndreas Gohr 56*1d94f4f4SAndreas Gohr /** @var string The last available remote update date */ 57*1d94f4f4SAndreas Gohr public $lastUpdate; 58*1d94f4f4SAndreas Gohr 59*1d94f4f4SAndreas Gohr /** @var string The download URL for this extension */ 60*1d94f4f4SAndreas Gohr public string $downloadURL; 61*1d94f4f4SAndreas Gohr 62*1d94f4f4SAndreas Gohr /** 63*1d94f4f4SAndreas Gohr * Constructor 64*1d94f4f4SAndreas Gohr * 65*1d94f4f4SAndreas Gohr * @param Extension $extension The extension to create the response for 66*1d94f4f4SAndreas Gohr */ 67*1d94f4f4SAndreas Gohr public function __construct(Extension $extension) 68*1d94f4f4SAndreas Gohr { 69*1d94f4f4SAndreas Gohr $this->extension = $extension; 70*1d94f4f4SAndreas Gohr $this->type = $extension->getType(); 71*1d94f4f4SAndreas Gohr $this->id = $extension->getId(); 72*1d94f4f4SAndreas Gohr $this->base = $extension->getBase(); 73*1d94f4f4SAndreas Gohr $this->name = $extension->getDisplayName(); 74*1d94f4f4SAndreas Gohr $this->version = $extension->getInstalledVersion(); 75*1d94f4f4SAndreas Gohr $this->author = $extension->getAuthor(); 76*1d94f4f4SAndreas Gohr $this->description = $extension->getDescription(); 77*1d94f4f4SAndreas Gohr $this->isInstalled = $extension->isInstalled(); 78*1d94f4f4SAndreas Gohr $this->isEnabled = $extension->isEnabled(); 79*1d94f4f4SAndreas Gohr $this->updateAvailable = $extension->isUpdateAvailable(); 80*1d94f4f4SAndreas Gohr $this->isBundled = $extension->isBundled(); 81*1d94f4f4SAndreas Gohr $this->isGitControlled = $extension->isGitControlled(); 82*1d94f4f4SAndreas Gohr $this->componentTypes = $extension->getComponentTypes(); 83*1d94f4f4SAndreas Gohr $this->lastUpdate = $extension->getLastUpdate(); 84*1d94f4f4SAndreas Gohr $this->url = $extension->getURL(); 85*1d94f4f4SAndreas Gohr $this->downloadURL = $extension->getDownloadURL(); 86*1d94f4f4SAndreas Gohr 87*1d94f4f4SAndreas Gohr // Add notices 88*1d94f4f4SAndreas Gohr $this->notices = array_merge(...array_values(Notice::list($extension))); 89*1d94f4f4SAndreas Gohr } 90*1d94f4f4SAndreas Gohr 91*1d94f4f4SAndreas Gohr /** @inheritdoc */ 92*1d94f4f4SAndreas Gohr public function __toString() 93*1d94f4f4SAndreas Gohr { 94*1d94f4f4SAndreas Gohr return $this->extension->getId(); 95*1d94f4f4SAndreas Gohr } 96*1d94f4f4SAndreas Gohr} 97