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:
| Property | Type | Description |
|---|---|---|
slug | string | Unique extension identifier |
name | string | Display name |
type | string | theme, plugin, or widget |
version | string | Latest available version |
installed_version | string|null | Installed version (null if not installed) |
price | float | 0.00 for free extensions |
download_url | string | ZIP 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
- POSTs
{key, slug, type}tohttps://pubvana.net/api/license/validate - On success, calls
installFree($downloadUrl)with the URL returned by the validation endpoint - Saves the license key to
marketplace_licensestable - 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.