Skip to content

Commit

Permalink
feat(update): put /update handler back in case of problems + phpactor…
Browse files Browse the repository at this point in the history
… lsp support
  • Loading branch information
Florian Schmitt committed Oct 10, 2024
1 parent 18258ba commit f75f60c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .phpactor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "/phpactor.schema.json",
"language_server_php_cs_fixer.enabled": true
}
28 changes: 28 additions & 0 deletions handlers/UpdateHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use YesWiki\Core\YesWikiHandler;
use YesWiki\Security\Controller\SecurityController;

class UpdateHandler extends YesWikiHandler
{
public function run(): string
{
if ($this->getService(SecurityController::class)->isWikiHibernated()) {
throw new \Exception(_t('WIKI_IN_HIBERNATION'));
}

$output = '';

if ($this->wiki->UserIsAdmin()) {
$res = [];
exec('./yeswicli migrate', $res);
$output .= implode('<br>', $res);
} else {
$output .= '<div class="alert alert-danger">' . _t('ACLS_RESERVED_FOR_ADMINS') . '</div>';
}

return $this->renderInSquelette('@core/handlers/update.twig', [
'output' => $output,
]);
}
}
1 change: 1 addition & 0 deletions templates/handlers/update.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{output|raw}}

0 comments on commit f75f60c

Please sign in to comment.