diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..2d37e13 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,7 @@ +name: PHP CS Fixer + +on: push + +jobs: + fixers: + uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main diff --git a/Events.php b/Events.php index 46a9495..20d7bc4 100644 --- a/Events.php +++ b/Events.php @@ -49,11 +49,11 @@ public static function onFooterMenuInit($event) $page = Page::getPage($pageKey); if ($page !== null) { $sortOrder += 10; - $event->sender->addItem(array( + $event->sender->addItem([ 'label' => $page->title, 'url' => Url::to(['/legal/page/view', 'pageKey' => $pageKey], true), 'sortOrder' => $sortOrder, - )); + ]); } } @@ -141,7 +141,7 @@ public static function onBeforeControllerAction(ActionEvent $event) $event->result = Yii::$app->response->redirect(['/legal/page/update']); } // Show legal pages in full screen with confirm form, one by one (after account creation) - elseif($registrationCheck->showTermsCheck() || $registrationCheck->showPrivacyCheck()) { + elseif ($registrationCheck->showTermsCheck() || $registrationCheck->showPrivacyCheck()) { $event->isValid = false; $event->result = Yii::$app->response->redirect(['/legal/page/confirm']); } diff --git a/Module.php b/Module.php index 758541a..3c36b76 100644 --- a/Module.php +++ b/Module.php @@ -17,7 +17,7 @@ class Module extends \humhub\components\Module * @inheritdoc */ public $resourcesPath = 'resources'; - + /** * @inheritdoc */ diff --git a/assets/Assets.php b/assets/Assets.php index ac004d3..83a8d22 100644 --- a/assets/Assets.php +++ b/assets/Assets.php @@ -11,19 +11,18 @@ class Assets extends AssetBundle { - public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; public $sourcePath = '@legal/resources'; public $css = [ - 'cookieconsent.min.css' + 'cookieconsent.min.css', ]; public $js = [ - 'cookieconsent.min.js' + 'cookieconsent.min.js', ]; } diff --git a/assets/ContentAssets.php b/assets/ContentAssets.php index 341eaff..b6ab721 100644 --- a/assets/ContentAssets.php +++ b/assets/ContentAssets.php @@ -23,7 +23,7 @@ class ContentAssets extends AssetBundle * @inheritdoc */ public $js = [ - 'js/humhub.legal.js' + 'js/humhub.legal.js', ]; /** @@ -51,4 +51,4 @@ public static function register($view) return parent::register($view); } -} \ No newline at end of file +} diff --git a/config.php b/config.php index 046312f..f5fce73 100644 --- a/config.php +++ b/config.php @@ -1,4 +1,6 @@ - $pages, 'languages' => $languages, 'defaultLanguage' => $this->module->getDefaultLanguage(), - 'pageKey' => $pageKey + 'pageKey' => $pageKey, ]); } @@ -117,4 +116,4 @@ protected function getPages($pageKey) return $pages; } -} \ No newline at end of file +} diff --git a/controllers/ExportController.php b/controllers/ExportController.php index ae1f00a..3811418 100644 --- a/controllers/ExportController.php +++ b/controllers/ExportController.php @@ -1,74 +1,74 @@ -module->isEnabledExportUserData(); - } - - public function actionIndex() - { - return $this->render('index', [ - 'service' => ExportService::instance(), - ]); - } - - public function actionRequest() - { - if (ExportService::instance()->requestPackage()) { - $this->view->success(Yii::t('LegalModule.base', 'The exporting of your data has been started, please wait some time.')); - } else { - $this->view->error('Cannot start the exporting of your data, please try again.'); - } - - return $this->redirect(['index']); - } - - public function actionDownload() - { - $package = ExportService::instance()->downloadPackage(); - - if ($package === null) { - throw new NotFoundHttpException(); - } - - return $package; - } - - public function actionDelete() - { - if (ExportService::instance()->deletePackage()) { - $this->view->success(Yii::t('LegalModule.base', 'The package has been deleted.')); - } else { - $this->view->error('Cannot delete the package, please try again.'); - } - - return $this->redirect(['index']); - } -} +module->isEnabledExportUserData(); + } + + public function actionIndex() + { + return $this->render('index', [ + 'service' => ExportService::instance(), + ]); + } + + public function actionRequest() + { + if (ExportService::instance()->requestPackage()) { + $this->view->success(Yii::t('LegalModule.base', 'The exporting of your data has been started, please wait some time.')); + } else { + $this->view->error('Cannot start the exporting of your data, please try again.'); + } + + return $this->redirect(['index']); + } + + public function actionDownload() + { + $package = ExportService::instance()->downloadPackage(); + + if ($package === null) { + throw new NotFoundHttpException(); + } + + return $package; + } + + public function actionDelete() + { + if (ExportService::instance()->deletePackage()) { + $this->view->success(Yii::t('LegalModule.base', 'The package has been deleted.')); + } else { + $this->view->error('Cannot delete the package, please try again.'); + } + + return $this->redirect(['index']); + } +} diff --git a/controllers/PageController.php b/controllers/PageController.php index 342f1c9..f4f0055 100644 --- a/controllers/PageController.php +++ b/controllers/PageController.php @@ -59,7 +59,7 @@ public function actionView($pageKey) return $this->render('view', [ 'page' => $page, - 'canManagePages' => $this->canManagePages() + 'canManagePages' => $this->canManagePages(), ]); } @@ -77,8 +77,7 @@ public function actionConfirm() if ($model->showTermsCheck()) { $model->restrictToSettingKey = RegistrationChecks::SETTING_KEY_TERMS; $page = Page::getPage(Page::PAGE_KEY_TERMS); - } - elseif ($model->showPrivacyCheck()) { + } elseif ($model->showPrivacyCheck()) { $model->restrictToSettingKey = RegistrationChecks::SETTING_KEY_PRIVACY; $page = Page::getPage(Page::PAGE_KEY_PRIVACY_PROTECTION); } @@ -99,7 +98,7 @@ public function actionConfirm() return $this->render('confirm', [ 'page' => $page, 'model' => $model, - 'module' => $this->module + 'module' => $this->module, ]); } @@ -134,7 +133,7 @@ public function actionUpdate() return $this->render('update', [ 'page' => $page, 'model' => $model, - 'module' => $this->module + 'module' => $this->module, ]); } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b7a2049..b6baf78 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 1.4.3 (Unreleased) -------------------------- - Fix #85: Fix downloading of large user export data file +- Enh #90: Use PHP CS Fixer 1.4.2 (September 13, 2024) -------------------------- diff --git a/migrations/uninstall.php b/migrations/uninstall.php index 78b9a52..9dbca4a 100644 --- a/migrations/uninstall.php +++ b/migrations/uninstall.php @@ -9,7 +9,6 @@ class uninstall extends Migration { - public function up() { $this->dropTable('legal_page'); diff --git a/models/Page.php b/models/Page.php index 918f16c..c530026 100644 --- a/models/Page.php +++ b/models/Page.php @@ -10,20 +10,20 @@ /** * This is the model class for table "legal_page". * - * @property integer $id + * @property int $id * @property string $page_key * @property string $language * @property string $title * @property string $content - * @property integer $last_update + * @property int $last_update */ class Page extends ActiveRecord { - const PAGE_KEY_IMPRINT = 'imprint'; - const PAGE_KEY_TERMS = 'terms'; - const PAGE_KEY_PRIVACY_PROTECTION = 'privacy'; - const PAGE_KEY_COOKIE_NOTICE = 'cookies'; - const PAGE_KEY_LEGAL_UPDATE = 'update'; + public const PAGE_KEY_IMPRINT = 'imprint'; + public const PAGE_KEY_TERMS = 'terms'; + public const PAGE_KEY_PRIVACY_PROTECTION = 'privacy'; + public const PAGE_KEY_COOKIE_NOTICE = 'cookies'; + public const PAGE_KEY_LEGAL_UPDATE = 'update'; /** * @inheritdoc @@ -68,7 +68,7 @@ public function afterSave($insert, $changedAttributes) public function rules() { return [ - [['title', 'content'], 'safe'] + [['title', 'content'], 'safe'], ]; } diff --git a/models/RegistrationChecks.php b/models/RegistrationChecks.php index f1be718..678cdaf 100644 --- a/models/RegistrationChecks.php +++ b/models/RegistrationChecks.php @@ -23,10 +23,9 @@ */ class RegistrationChecks extends Model { - - const SETTING_KEY_TERMS = 'acceptedTerms'; - const SETTING_KEY_PRIVACY = 'acceptedPrivacy'; - const SETTING_KEY_AGE = 'acceptedAge'; + public const SETTING_KEY_TERMS = 'acceptedTerms'; + public const SETTING_KEY_PRIVACY = 'acceptedPrivacy'; + public const SETTING_KEY_AGE = 'acceptedAge'; public $ageCheck; public $termsCheck; @@ -66,7 +65,7 @@ public function attributeLabels() return [ 'ageCheck' => Yii::t('LegalModule.base', 'I am older than {age} years', ['age' => \Yii::$app->getModule('legal')->getMinimumAge()]), 'termsCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Terms and Conditions'), - 'dataPrivacyCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Privacy Policy') + 'dataPrivacyCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Privacy Policy'), ]; } diff --git a/tests/codeception/_support/AcceptanceTester.php b/tests/codeception/_support/AcceptanceTester.php index 6cf5a59..9cc839e 100644 --- a/tests/codeception/_support/AcceptanceTester.php +++ b/tests/codeception/_support/AcceptanceTester.php @@ -150,4 +150,4 @@ public function testPage(string $page, string $title, string $content, string $a $this->amUser1(true); $this->dontSee($title, '.panel-heading'); } -} \ No newline at end of file +} diff --git a/tests/codeception/acceptance/LegalCest.php b/tests/codeception/acceptance/LegalCest.php index 4044377..49c55e3 100644 --- a/tests/codeception/acceptance/LegalCest.php +++ b/tests/codeception/acceptance/LegalCest.php @@ -37,19 +37,23 @@ public function testImprint(AcceptanceTester $I) public function testTermsAndConditions(AcceptanceTester $I) { $I->wantTo('test terms and conditions'); - $I->testPage(Page::PAGE_KEY_TERMS, + $I->testPage( + Page::PAGE_KEY_TERMS, 'Test Terms and Conditions title', 'Test Terms and Conditions content', - 'termscheck'); + 'termscheck', + ); } public function testPrivacyPolicy(AcceptanceTester $I) { $I->wantTo('test privacy policy'); - $I->testPage(Page::PAGE_KEY_PRIVACY_PROTECTION, + $I->testPage( + Page::PAGE_KEY_PRIVACY_PROTECTION, 'Test Privacy Policy title', 'Test Privacy Policy content', - 'dataprivacycheck'); + 'dataprivacycheck', + ); } public function testCookie(AcceptanceTester $I) @@ -78,12 +82,12 @@ public function testUpdate(AcceptanceTester $I) $pages = [ Page::PAGE_KEY_TERMS => [ 'title' => 'Test Terms and Conditions title', - 'content' => 'Test Terms and Conditions content' + 'content' => 'Test Terms and Conditions content', ], Page::PAGE_KEY_LEGAL_UPDATE => [ 'title' => 'Test Legal Update title', - 'content' => 'Test Legal Update content' - ] + 'content' => 'Test Legal Update content', + ], ]; $I->amAdmin(); @@ -132,4 +136,4 @@ public function testAgeVerification(AcceptanceTester $I) $I->amUser1(true); $I->dontSee($title, '.panel-heading'); } -} \ No newline at end of file +} diff --git a/tests/config/test.php b/tests/config/test.php index d55661a..5670ad1 100644 --- a/tests/config/test.php +++ b/tests/config/test.php @@ -7,5 +7,5 @@ return [ 'modules' => ['legal'], - 'fixtures' => ['default'] + 'fixtures' => ['default'], ]; diff --git a/widgets/AdminMenu.php b/widgets/AdminMenu.php index afe8f0c..048967f 100644 --- a/widgets/AdminMenu.php +++ b/widgets/AdminMenu.php @@ -13,7 +13,6 @@ class AdminMenu extends \humhub\widgets\BaseMenu { - public $template = "@humhub/widgets/views/tabMenu"; public function init() diff --git a/widgets/Content.php b/widgets/Content.php index 316bbd1..58d7cd3 100644 --- a/widgets/Content.php +++ b/widgets/Content.php @@ -40,7 +40,7 @@ public function run() return $this->render('content', [ 'content' => $this->content, 'richtext' => $this->richtext, - 'options' => $this->getOptions() + 'options' => $this->getOptions(), ]); } -} \ No newline at end of file +} diff --git a/widgets/CookieNote.php b/widgets/CookieNote.php index 7dcb655..c41bae5 100644 --- a/widgets/CookieNote.php +++ b/widgets/CookieNote.php @@ -6,11 +6,11 @@ */ namespace humhub\modules\legal\widgets; + use humhub\components\Widget; use humhub\modules\legal\models\Page; use yii\web\HttpException; - /** * Class CookieNote * @package humhub\modules\legal\widgets @@ -26,4 +26,4 @@ public function run() return $this->render('cookies', ['page' => $page]); } -} \ No newline at end of file +}