Skip to content

Commit

Permalink
Merge pull request #30 from humhub/enh/php-cs-fixer
Browse files Browse the repository at this point in the history
Use PHP CS Fixer
  • Loading branch information
luke- authored Oct 11, 2024
2 parents be89108 + 822b174 commit 7df840a
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 90 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: PHP CS Fixer

on: push

jobs:
tests:
uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main
1 change: 0 additions & 1 deletion Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class Events
{

public static function onFileHandlerCollection($event)
{
/* @var $collection FileHandlerCollection */
Expand Down
4 changes: 2 additions & 2 deletions assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class Assets extends AssetBundle
* @inheritdoc
*/
public $jsOptions = [
'position' => View::POS_END
'position' => View::POS_END,
];

/**
* @inheritdoc
*/
public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

}
2 changes: 1 addition & 1 deletion controllers/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function actionIndex()
} else {
return $this->asJson([
'success' => false,
'output' => $this->renderAjax('index', ['model' => $model])
'output' => $this->renderAjax('index', ['model' => $model]),
]);
}
}
Expand Down
5 changes: 2 additions & 3 deletions controllers/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

class EditController extends BaseFileController
{

/**
* Edit the text file in modal
*
*
* @return string
* @throws HttpException
*/
Expand All @@ -41,7 +40,7 @@ public function actionIndex()

return $this->renderAjax('index', [
'fileUpdate' => $fileUpdate,
'file' => $file
'file' => $file,
]);
}

Expand Down
3 changes: 1 addition & 2 deletions controllers/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

class ViewController extends BaseFileController
{

/**
* View the text file in modal
*
*
* @return string
* @throws HttpException
*/
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Changelog
- Fix #3: Fix CodeMirror Editor
- Enh #19: Improve extension handling
- Fix: Add autofocus on file creation modal box (for HumHub 1.17 - see https://github.com/humhub/humhub/issues/7136)
- Enh #30: Use PHP CS Fixer
3 changes: 1 addition & 2 deletions filehandler/CreateFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class CreateFileHandler extends BaseFileHandler
{

/**
* @inheritdoc
*/
Expand All @@ -29,7 +28,7 @@ public function getLinkAttributes()
'data-action-url' => Url::to(['/text-editor/create']),
'data-action-click' => 'ui.modal.load',
'data-modal-id' => 'texteditor-modal',
'data-modal-close' => ''
'data-modal-close' => '',
];
}

Expand Down
3 changes: 1 addition & 2 deletions filehandler/EditFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class EditFileHandler extends BaseFileHandler
{

/**
* @inheritdoc
*/
Expand All @@ -34,7 +33,7 @@ public function getLinkAttributes()
'data-action-url' => Url::to(['/text-editor/edit', 'guid' => $this->file->guid]),
'data-action-click' => 'ui.modal.load',
'data-modal-id' => 'texteditor-modal',
'data-modal-close' => ''
'data-modal-close' => '',
];
}

Expand Down
3 changes: 1 addition & 2 deletions filehandler/ViewFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class ViewFileHandler extends BaseFileHandler
{

/**
* @inheritdoc
*/
Expand All @@ -34,7 +33,7 @@ public function getLinkAttributes()
'data-action-url' => Url::to(['/text-editor/view', 'guid' => $this->file->guid]),
'data-action-click' => 'ui.modal.load',
'data-modal-id' => 'texteditor-modal',
'data-modal-close' => ''
'data-modal-close' => '',
];
}

Expand Down
1 change: 0 additions & 1 deletion models/FileUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class FileUpdate extends Model
{

/**
* @var File File for updating its content
*/
Expand Down
146 changes: 73 additions & 73 deletions models/forms/ConfigForm.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\text_editor\models\forms;

use humhub\components\SettingsManager;
use humhub\modules\text_editor\Module;
use Yii;
use yii\base\Model;

/**
* Form for Text Editor Module Settings
*/
class ConfigForm extends Model
{
public bool $allowNewFiles = false;

protected ?SettingsManager $settings = null;

/**
* @inheritdoc
*/
public function init()
{
$this->allowNewFiles = (bool) $this->getSettings()->get('allowNewFiles', false);
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['allowNewFiles'], 'boolean'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'allowNewFiles' => Yii::t('TextEditorModule.base', 'Allow creation of new text files'),
];
}

public function save(): bool
{
if (!$this->validate()) {
return false;
}

$this->getSettings()->set('allowNewFiles', $this->allowNewFiles);

return true;
}

protected function getSettings(): SettingsManager
{
if ($this->settings === null) {
/* @var Module $module */
$module = Yii::$app->getModule('text-editor');
$this->settings = $module->settings;
}

return $this->settings;
}
}
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\text_editor\models\forms;

use humhub\components\SettingsManager;
use humhub\modules\text_editor\Module;
use Yii;
use yii\base\Model;

/**
* Form for Text Editor Module Settings
*/
class ConfigForm extends Model
{
public bool $allowNewFiles = false;

protected ?SettingsManager $settings = null;

/**
* @inheritdoc
*/
public function init()
{
$this->allowNewFiles = (bool) $this->getSettings()->get('allowNewFiles', false);
}

/**
* @inheritdoc
*/
public function rules()
{
return [
[['allowNewFiles'], 'boolean'],
];
}

/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'allowNewFiles' => Yii::t('TextEditorModule.base', 'Allow creation of new text files'),
];
}

public function save(): bool
{
if (!$this->validate()) {
return false;
}

$this->getSettings()->set('allowNewFiles', $this->allowNewFiles);

return true;
}

protected function getSettings(): SettingsManager
{
if ($this->settings === null) {
/* @var Module $module */
$module = Yii::$app->getModule('text-editor');
$this->settings = $module->settings;
}

return $this->settings;
}
}
2 changes: 1 addition & 1 deletion tests/codeception/config/unit.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

return \tests\codeception\_support\HumHubTestConfiguration::getSuiteConfig('unit');
return \tests\codeception\_support\HumHubTestConfiguration::getSuiteConfig('unit');

0 comments on commit 7df840a

Please sign in to comment.