mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Cache licence
This commit is contained in:
parent
c743e409ba
commit
e73ac36f7b
@ -15,8 +15,10 @@ use humhub\modules\marketplace\Module;
|
|||||||
use humhub\modules\space\models\Space;
|
use humhub\modules\space\models\Space;
|
||||||
use humhub\modules\user\models\User;
|
use humhub\modules\user\models\User;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\Component;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\db\StaleObjectException;
|
use yii\db\StaleObjectException;
|
||||||
|
use yii\base\Event;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,9 +26,20 @@ use yii\db\StaleObjectException;
|
|||||||
*
|
*
|
||||||
* @package humhub\modules\marketplace\components
|
* @package humhub\modules\marketplace\components
|
||||||
*/
|
*/
|
||||||
class LicenceManager
|
class LicenceManager extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Licence
|
||||||
|
*/
|
||||||
|
private static $_licence = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @event Event an event that is triggered when the current licence is requested
|
||||||
|
*/
|
||||||
|
const EVENT_GET_LICENCE = 'getLicence';
|
||||||
|
|
||||||
|
|
||||||
const SETTING_KEY_PE_LICENCE_KEY = 'licenceKey';
|
const SETTING_KEY_PE_LICENCE_KEY = 'licenceKey';
|
||||||
const SETTING_KEY_PE_LAST_FETCH = 'lastFetch';
|
const SETTING_KEY_PE_LAST_FETCH = 'lastFetch';
|
||||||
const SETTING_KEY_PE_LICENCED_TO = 'licencedTo';
|
const SETTING_KEY_PE_LICENCED_TO = 'licencedTo';
|
||||||
@ -35,12 +48,29 @@ class LicenceManager
|
|||||||
const PE_FETCH_INTERVAL = 60 * 60 * 2;
|
const PE_FETCH_INTERVAL = 60 * 60 * 2;
|
||||||
const PE_FETCH_TOLERANCE = 60 * 60 * 24 * 2;
|
const PE_FETCH_TOLERANCE = 60 * 60 * 24 * 2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current licence object
|
* Returns the current licence object
|
||||||
*
|
*
|
||||||
* @return Licence
|
* @return Licence
|
||||||
*/
|
*/
|
||||||
public static function get()
|
public static function get()
|
||||||
|
{
|
||||||
|
if (static::$_licence === null) {
|
||||||
|
static::$_licence = static::create();
|
||||||
|
Event::trigger(static::class, static::EVENT_GET_LICENCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return static::$_licence;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current licence object
|
||||||
|
*
|
||||||
|
* @return Licence
|
||||||
|
*/
|
||||||
|
private static function create()
|
||||||
{
|
{
|
||||||
$settings = static::getModule()->settings;
|
$settings = static::getModule()->settings;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user