====== ThemeLicenseService ======
**Layer:** ''Service'' · **Source:** ''lib/service/ThemeLicenseService.php:21'' (lines 21–321)
----
class ThemeLicenseService
ThemeLicenseService
HTTP client that validates premium theme licenses against the MyBlog
license API (https://myblog.local/api/v2/licenses/*). Requests are
HMAC-signed using the per-product license_secret embedded in the
theme's theme.ini file.
======= Docblock Metadata =======
^ Tag ^ Value ^
| ''@category'' | Class ThemeLicenseService |
| ''@author'' | MyBlog |
| ''@license'' | MIT |
| ''@version'' | 1.0.0 |
| ''@since'' | Since Release 1.0.0 |
======= Inheritance =======
//No parent, interface or trait. This is a root type.//
======= Constants (0) =======
//None.//
======= Properties (2) =======
^ Visibility ^ Type ^ Name ^ Default ^ Line ^
| ''protected'' | ''(untyped)'' | ''$apiBaseUrl'' | | 28 |
| ''private'' | ''(untyped)'' | ''$timeout'' | | 35 |
======= Methods (10) =======
^ Visibility ^ Method ^ Summary ^ Line ^
| public | ''__construct()'' | Constructor | 43 |
| public | ''readThemeConfig()'' | Read the theme.ini configuration for a given theme directory. | 55 |
| public | ''isPremiumTheme()'' | Determine whether a theme is a premium theme. | 74 |
| public | ''activate()'' | Activate a license key against the MyBlog license API. | 97 |
| public | ''validate()'' | Validate an already-activated license. | 120 |
| public | ''deactivate()'' | Deactivate a theme license, releasing one activation slot. | 143 |
| protected | ''post()'' | Send an HMAC-signed POST request to the license API. | 167 |
| private | ''postCurl()'' | Send the request using cURL. | 198 |
| private | ''postStream()'' | Send the request using stream context (fallback when cURL is absent). | 234 |
| protected | ''parseResponse()'' | Parse the JSON response from the license API. | 278 |
======== __construct() ========
public function __construct($apiBaseUrl = null, $timeout = 10)
//lines 43–47 (5)//
Constructor
^ Parameter ^ Type ^ Default ^ Description ^
| ''$apiBaseUrl'' | ''(untyped)'' | ''null'' | Override the license API base URL. |
| ''$timeout'' | ''(untyped)'' | ''10'' | Request timeout in seconds. |
======== readThemeConfig() ========
public function readThemeConfig($themeDirectory)
//lines 55–66 (12)//
Read the theme.ini configuration for a given theme directory.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$themeDirectory'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — array
======== isPremiumTheme() ========
public function isPremiumTheme($themeDirectory)
//lines 74–83 (10)//
Determine whether a theme is a premium theme.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$themeDirectory'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — bool
======== activate() ========
public function activate($licenseKey, $domain, $productSecret, $productId)
//lines 97–107 (11)//
Activate a license key against the MyBlog license API.
POST /api/v2/licenses/activate/{product_id}
Body: {"license_key": "...", "domain": "..."}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$licenseKey'' | ''(untyped)'' | //required// | The license key entered by the admin. |
| ''$domain'' | ''(untyped)'' | //required// | The domain where the theme is installed. |
| ''$productSecret'' | ''(untyped)'' | //required// | Per-product license_secret embedded in the theme. |
| ''$productId'' | ''(untyped)'' | //required// | MyBlog store product ID for this theme. |
**Returns:** ''(none declared)'' — array{success: bool, message: string, data?: array}
======== validate() ========
public function validate($licenseKey, $productId, $productSecret)
//lines 120–130 (11)//
Validate an already-activated license.
POST /api/v2/licenses/validate
Body: {"license_key": "...", "product_id": N}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$licenseKey'' | ''(untyped)'' | //required// | //none// |
| ''$productId'' | ''(untyped)'' | //required// | //none// |
| ''$productSecret'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — array{success: bool, message: string, data?: array}
======== deactivate() ========
public function deactivate($licenseKey, $productId, $productSecret)
//lines 143–153 (11)//
Deactivate a theme license, releasing one activation slot.
POST /api/v2/licenses/deactivate
Body: {"license_key": "...", "product_id": N}
^ Parameter ^ Type ^ Default ^ Description ^
| ''$licenseKey'' | ''(untyped)'' | //required// | //none// |
| ''$productId'' | ''(untyped)'' | //required// | //none// |
| ''$productSecret'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — array{success: bool, message: string, data?: array}
======== post() ========
protected function post($url, $body, $secret)
//lines 167–188 (22)//
Send an HMAC-signed POST request to the license API.
Signature scheme (mirrors MyBlog ApiAuthService::verifyHmacSignature):
payload = "{timestamp}.{nonce}.{body}"
signature = hash_hmac('sha256', payload, secret)
^ Parameter ^ Type ^ Default ^ Description ^
| ''$url'' | ''(untyped)'' | //required// | //none// |
| ''$body'' | ''(untyped)'' | //required// | //none// |
| ''$secret'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — array{success: bool, message: string, data?: array}
======== postCurl() ========
private function postCurl($url, $body, array $headers)
//lines 198–224 (27)//
Send the request using cURL.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$url'' | ''(untyped)'' | //required// | //none// |
| ''$body'' | ''(untyped)'' | //required// | //none// |
| ''$headers'' | ''array'' | //required// | //none// |
**Returns:** ''(none declared)'' — array
======== postStream() ========
private function postStream($url, $body, array $headers)
//lines 234–269 (36)//
Send the request using stream context (fallback when cURL is absent).
^ Parameter ^ Type ^ Default ^ Description ^
| ''$url'' | ''(untyped)'' | //required// | //none// |
| ''$body'' | ''(untyped)'' | //required// | //none// |
| ''$headers'' | ''array'' | //required// | //none// |
**Returns:** ''(none declared)'' — array
======== parseResponse() ========
protected function parseResponse($response, $httpCode)
//lines 278–320 (43)//
Parse the JSON response from the license API.
^ Parameter ^ Type ^ Default ^ Description ^
| ''$response'' | ''(untyped)'' | //required// | //none// |
| ''$httpCode'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — array
----
//This page is generated from source by 'tools/gendoc'. Edits will be overwritten.//