chore: sync module from working instance and add install guide

This commit is contained in:
Kelin Rescue Hub
2026-04-09 14:11:34 -04:00
parent 20adb1bd1e
commit 039c12233e
23 changed files with 4577 additions and 394 deletions

View File

@@ -5,11 +5,13 @@ namespace humhub\modules\animal_management\controllers;
use humhub\modules\animal_management\models\Animal;
use humhub\modules\animal_management\models\forms\DisplaySettingsForm;
use humhub\modules\animal_management\models\forms\FieldDefinitionSettingsForm;
use humhub\modules\animal_management\services\ModuleSetupService;
use humhub\modules\content\components\ContentContainerController;
use humhub\modules\content\components\ContentContainerControllerAccess;
use humhub\modules\rescue_foundation\widgets\RescueSettingsMenu;
use humhub\modules\space\models\Space;
use Yii;
use yii\web\BadRequestHttpException;
class SettingsController extends ContentContainerController
{
@@ -53,6 +55,37 @@ class SettingsController extends ContentContainerController
'animalCount' => (int)$animalCount,
'fieldSettingsForm' => $fieldSettingsForm,
'displaySettingsForm' => $displaySettingsForm,
'space' => $this->contentContainer,
]);
}
public function actionSetup()
{
if (!Yii::$app->request->isPost) {
throw new BadRequestHttpException('Invalid request method.');
}
if (!$this->contentContainer instanceof Space) {
$this->view->error(Yii::t('AnimalManagementModule.base', 'Setup can only be run inside a space.'));
return $this->redirect($this->contentContainer->createUrl('/animal_management/settings'));
}
try {
$result = ModuleSetupService::runForSpace($this->contentContainer);
$appliedCount = count($result['applied'] ?? []);
if ($appliedCount > 0) {
$this->view->success(Yii::t('AnimalManagementModule.base', 'Setup completed. Applied {count} migration(s).', [
'count' => $appliedCount,
]));
} else {
$this->view->success(Yii::t('AnimalManagementModule.base', 'Setup completed. No pending migrations were found.'));
}
} catch (\Throwable $e) {
Yii::error($e, 'animal_management.setup');
$this->view->error(Yii::t('AnimalManagementModule.base', 'Setup failed. Please check logs and try again.'));
}
return $this->redirect($this->contentContainer->createUrl('/animal_management/settings'));
}
}