Skip to content

Commit

Permalink
Merge pull request #359 from silinternational/feature/decouple-sheets…
Browse files Browse the repository at this point in the history
…-component

Pass config values to `Sheets` instead of internally retrieving them
  • Loading branch information
forevermatt authored Sep 5, 2024
2 parents b4829f4 + 7cf39d9 commit 0bfd3a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 0 additions & 6 deletions application/common/components/Sheets.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ class Sheets extends Component
*/
public function init()
{
$this->applicationName = \Yii::$app->params['google']['applicationName'];
$this->jsonAuthFilePath = \Yii::$app->params['google']['jsonAuthFilePath'];
$this->jsonAuthString = \Yii::$app->params['google']['jsonAuthString'];
$this->delegatedAdmin = \Yii::$app->params['google']['delegatedAdmin'];
$this->spreadsheetId = \Yii::$app->params['google']['spreadsheetId'];

if (!empty($this->jsonAuthFilePath)) {
if (file_exists($this->jsonAuthFilePath)) {
$this->jsonAuthString = \file_get_contents($this->jsonAuthFilePath);
Expand Down
8 changes: 7 additions & 1 deletion application/common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,13 @@ public static function exportToSheets()
'status' => 'start',
]);

$googleSheetsClient = new Sheets();
$googleSheetsClient = new Sheets([
'applicationName' => Yii::$app->params['google']['applicationName'],
'jsonAuthFilePath' => Yii::$app->params['google']['jsonAuthFilePath'],
'jsonAuthString' => Yii::$app->params['google']['jsonAuthString'],
'delegatedAdmin' => Yii::$app->params['google']['delegatedAdmin'],
'spreadsheetId' => Yii::$app->params['google']['spreadsheetId'],
]);

$activeUsers = User::find()->where(['active' => 'yes'])->all();
$table = [];
Expand Down

0 comments on commit 0bfd3a5

Please sign in to comment.