コード例 #1
0
 /**
  * @param string $licenceKey
  * @return int
  */
 public function importLicence($licenceKey)
 {
     $persister = new \Shopware_Components_LicensePersister($this->connection);
     $info = \Shopware_Components_License::readLicenseInfo($licenceKey);
     if ($info == false) {
         throw new \RuntimeException();
     }
     return $persister->saveLicense($info, true);
 }
コード例 #2
0
 /**
  * function to get expired plugins
  * @return array
  */
 public function getExpiredPluginLicenses()
 {
     if ($this->checkLicensePluginIsInstalled() == false) {
         return [];
     }
     //get all licenses
     $expiredPlugins = [];
     $expireDays = 14;
     //Days to warn before plugin gets expired
     $licenses = $this->getLicences();
     if (empty($licenses)) {
         return [];
     }
     //decode all license and get info, check for expiring
     foreach ($licenses as $license) {
         $info = \Shopware_Components_License::readLicenseInfo($license['license']);
         $expirationDate = $this->getLicenceExpirationDate($info);
         if ($expirationDate === null) {
             continue;
         }
         $diff = $expirationDate->diff(new \DateTime('now'));
         if ($diff->invert == 1 && $diff->days <= $expireDays) {
             $expiredPlugins[] = ['expireDate' => $expirationDate, 'plugin' => $info['label']];
         }
     }
     return $expiredPlugins;
 }