chore: sync module from working instance and add install guide
This commit is contained in:
@@ -7,8 +7,10 @@ use humhub\modules\content\components\ContentContainerControllerAccess;
|
||||
use humhub\modules\rescue_foundation\widgets\RescueSettingsMenu;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\space_profiles\models\forms\SpaceProfileForm;
|
||||
use humhub\modules\space_profiles\services\ModuleSetupService;
|
||||
use Yii;
|
||||
use yii\web\UploadedFile;
|
||||
use yii\web\BadRequestHttpException;
|
||||
|
||||
class SettingsController extends ContentContainerController
|
||||
{
|
||||
@@ -41,4 +43,34 @@ class SettingsController extends ContentContainerController
|
||||
'subNav' => $subNav,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSetup()
|
||||
{
|
||||
if (!Yii::$app->request->isPost) {
|
||||
throw new BadRequestHttpException('Invalid request method.');
|
||||
}
|
||||
|
||||
if (!$this->contentContainer instanceof Space) {
|
||||
$this->view->error(Yii::t('SpaceProfilesModule.base', 'Setup can only be run inside a space.'));
|
||||
return $this->redirect($this->contentContainer->createUrl('/space_profiles/settings'));
|
||||
}
|
||||
|
||||
try {
|
||||
$result = ModuleSetupService::runForSpace($this->contentContainer);
|
||||
$appliedCount = count($result['applied'] ?? []);
|
||||
|
||||
if ($appliedCount > 0) {
|
||||
$this->view->success(Yii::t('SpaceProfilesModule.base', 'Setup completed. Applied {count} migration(s).', [
|
||||
'count' => $appliedCount,
|
||||
]));
|
||||
} else {
|
||||
$this->view->success(Yii::t('SpaceProfilesModule.base', 'Setup completed. No pending migrations were found.'));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Yii::error($e, 'space_profiles.setup');
|
||||
$this->view->error(Yii::t('SpaceProfilesModule.base', 'Setup failed. Please check logs and try again.'));
|
||||
}
|
||||
|
||||
return $this->redirect($this->contentContainer->createUrl('/space_profiles/settings'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user