User Docs Developer Docs | |

MarketplaceService

Registered as service('marketplace'). Fetches the extension catalogue from the Pubvana Marketplace API, handles installation of free and licensed extensions, and manages the local cache.

API Endpoint

Primary: https://pubvana.net/api/marketplace — fetched with a 1-hour cache. Falls back to a mock dataset if the API is unreachable (for development environments without internet access).

Return Types

All fetch methods return stdClass objects (not arrays). Each object has at minimum:

PropertyTypeDescription
slugstringUnique extension identifier
namestringDisplay name
typestringtheme, plugin, or widget
versionstringLatest available version
installed_versionstring|nullInstalled version (null if not installed)
pricefloat0.00 for free extensions
download_urlstringZIP download URL (free extensions)

Methods

fetchAll(): array

Returns all marketplace items (themes + plugins + widgets) as an array of stdClass objects.

$items = service('marketplace')->fetchAll();
foreach ($items as $item) {
    echo $item->name . ' ' . $item->version;
}

fetchThemes(): array

Returns only theme items.

fetchPlugins(): array

Returns only plugin items.

fetchWidgets(): array

Returns only widget items.

installFree(string $downloadUrl): bool

Downloads a ZIP from $downloadUrl, extracts it to the appropriate directory (themes/, plugins/, or widgets/ — determined by the ZIP's manifest), and runs discover() + sync() on the relevant service.

$ok = service('marketplace')->installFree($item->download_url);

installLicensed(string $key, string $slug, string $type): bool

  1. POSTs {key, slug, type} to https://pubvana.net/api/license/validate
  2. On success, calls installFree($downloadUrl) with the URL returned by the validation endpoint
  3. Saves the license key to marketplace_licenses table
  4. Returns true on success, false on validation failure or download error
$ok = service('marketplace')->installLicensed($licenseKey, 'ember', 'theme');

refreshCache(): void

Busts all marketplace_api_* cache keys, forcing the next fetch*() call to hit the live API.

service('marketplace')->refreshCache();

checkAndRevalidateIfDue(): void

Called on admin pageload (or by cron). Checks if any installed licensed extensions are due for revalidation (based on a configurable interval). Re-POSTs to the validation endpoint for each due license. Updates marketplace_licenses.last_checked and is_valid accordingly.