From 23219eed53d6c1647ff46df98171b0de66376303 Mon Sep 17 00:00:00 2001 From: RodrigoDornelles Date: Tue, 3 Aug 2021 10:41:41 -0300 Subject: [PATCH] finish plugin --- composer.json | 2 +- src/CookieConsent.php | 44 +++++++++++++++++++++++++++++++++++ src/CookieConsentAsset.php | 16 +++++++++++++ src/CookieConsentAssetCDN.php | 14 +++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/CookieConsent.php create mode 100644 src/CookieConsentAsset.php create mode 100644 src/CookieConsentAssetCDN.php diff --git a/composer.json b/composer.json index d3a1f33..c7f95bd 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "issues": "http://github.com/dynamikaweb/yii2-cookieconsent-widget/issues", "source": "http://github.com/dynamikaweb/yii2-cookieconsent-widget" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=7.0", "yiisoft/yii2": "*", diff --git a/src/CookieConsent.php b/src/CookieConsent.php new file mode 100644 index 0000000..89d496f --- /dev/null +++ b/src/CookieConsent.php @@ -0,0 +1,44 @@ +assetType == self::ASSET_TYPE_LOCAL) { + CookieConsentAsset::register($view); + } else { + CookieConsentAssetCDN::register($view); + } + + $view->registerJs(strtr('window.cookieconsent.initialise({pluginOptions});', [ + '{pluginOptions}' => Json::encode($this->pluginOptions), + ]), + $view::POS_END + ); + } + + /** + * @return null + */ + public function run() + { + $this->registerAssets($this->getView()); + return null; + } +} \ No newline at end of file diff --git a/src/CookieConsentAsset.php b/src/CookieConsentAsset.php new file mode 100644 index 0000000..c987f3a --- /dev/null +++ b/src/CookieConsentAsset.php @@ -0,0 +1,16 @@ +