/**
  * Retrieve a license by license key or token.
  *
  * If you specify a token, this method will ignore $licenseKey and just
  * look for the token. The returned license object will also include
  * the URL of the site associated with that token in a 'site_url' field.
  *
  * @param string|null $licenseKey
  * @param string|null $token
  * @throws InvalidArgumentException
  * @return Wslm_ProductLicense|null A license object, or null if the license doesn't exist.
  */
 public function loadLicense($licenseKey, $token = null)
 {
     if (!empty($token)) {
         $query = "SELECT licenses.*, tokens.site_url\n\t\t\t\t FROM\n\t\t\t\t \t`{$this->tablePrefix}licenses` AS licenses\n\t\t\t\t \tJOIN `{$this->tablePrefix}tokens` AS tokens\n\t\t\t\t \tON licenses.license_id = tokens.license_id\n\t\t\t\t WHERE tokens.token = ?";
         $params = array($token);
     } else {
         if (!empty($licenseKey)) {
             $query = "SELECT licenses.* FROM `{$this->tablePrefix}licenses` AS licenses\n\t\t\t\t WHERE license_key = ?";
             $params = array($licenseKey);
         } else {
             throw new InvalidArgumentException('You must specify a license key or a site token.');
         }
     }
     $license = $this->db->getRow($query, $params);
     if (!empty($license)) {
         //Also include the list of sites associated with this license.
         $license['sites'] = $this->loadLicenseSites($license['license_id']);
         $license = new Wslm_ProductLicense($license);
         $license['renewal_url'] = 'http://adminmenueditor.com/renew-license/';
         //TODO: Put this in a config of some sort instead.
         $license['upgrade_url'] = 'http://adminmenueditor.com/upgrade-license/';
     } else {
         $license = null;
     }
     return $license;
 }