diff --git a/README.md b/README.md index 0d3577f..876ced4 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,6 @@ return [ // 'scopes' => [], // 'quotaProject' => '', // 'userProject' => false, - // 'debug' => false, // 'prefix' => '', ], ], @@ -418,7 +417,7 @@ See: [masbug/flysystem-google-drive-ext](https://github.com/masbug/flysystem-goo Either run ```shell -composer require masbug/flysystem-google-drive-ext +composer require masbug/flysystem-google-drive-ext:^2.0 ``` or add @@ -443,7 +442,8 @@ return [ // 'teamDriveId' => '', // 'sharedFolderId' => '', // 'options' => [], - // 'debug' => false, + 'secret' => 'my-secret', // for secure route url + // 'action' => '/site/file', // action route // 'prefix' => '', ], ], diff --git a/src/GoogleCloudStorageComponent.php b/src/GoogleCloudStorageComponent.php index facfabc..e121876 100644 --- a/src/GoogleCloudStorageComponent.php +++ b/src/GoogleCloudStorageComponent.php @@ -31,7 +31,6 @@ * // 'scopes' => [], * // 'quotaProject' => '', * // 'userProject' => false, - * // 'debug' => false, * // 'prefix' => '', * ], * ], diff --git a/src/GoogleDriveComponent.php b/src/GoogleDriveComponent.php index 4ebd99e..47b3d0a 100644 --- a/src/GoogleDriveComponent.php +++ b/src/GoogleDriveComponent.php @@ -3,6 +3,7 @@ namespace diecoding\flysystem; use diecoding\flysystem\adapter\GoogleDriveAdapter; +use diecoding\flysystem\traits\UrlGeneratorComponentTrait; use Google\Client; use Google\Service\Drive; use yii\base\InvalidConfigException; @@ -22,7 +23,8 @@ * // 'teamDriveId' => '', * // 'sharedFolderId' => '', * // 'options' => [], - * // 'debug' => false, + * 'secret' => 'my-secret', // for secure route url + * // 'action' => '/site/file', // action route * // 'prefix' => '', * ], * ], @@ -34,6 +36,8 @@ */ class GoogleDriveComponent extends AbstractComponent { + use UrlGeneratorComponentTrait; + /** * @var string */ @@ -64,6 +68,11 @@ class GoogleDriveComponent extends AbstractComponent */ public $sharedFolderId; + /** + * @var string + */ + public $secret; + /** * @var array */ @@ -99,6 +108,12 @@ public function init() $this->options['sharedFolderId'] = $this->sharedFolderId; } + if (empty($this->secret)) { + throw new InvalidConfigException('The "secret" property must be set.'); + } + + $this->initEncrypter($this->secret); + parent::init(); }