Skip to content

Commit

Permalink
Merge pull request #14571 from jeabakker/features
Browse files Browse the repository at this point in the history
Features
  • Loading branch information
jdalsem committed Mar 8, 2024
2 parents ab55298 + 7a13226 commit 035a403
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Elgg\Request;
use Elgg\WebServices\Di\RestApiErrorHandler;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

/**
* Set custom error/exception handlers during rest api calls
Expand Down Expand Up @@ -44,14 +46,27 @@ public function __invoke(Request $request) {
*
* @return void
*/
public function exceptionHandler(\Throwable $throwable) {
public function exceptionHandler(\Throwable $throwable): void {
error_log('*** FATAL EXCEPTION (API) *** : ' . $throwable);

$code = $throwable->getCode() === 0 ? \ErrorResult::RESULT_FAIL : $throwable->getCode();
$result = new \ErrorResult($throwable->getMessage(), $code);

echo elgg_view_page($throwable->getMessage(), elgg_view('api/output', [
$output = elgg_view('api/output', [
'result' => $result,
]));
]);

$viewtype = elgg_get_viewtype();
switch ($viewtype) {
case 'json':
$response = new JsonResponse($output);
break;
default:
$response = new Response($output);
break;
}

$response->prepare(_elgg_services()->request);
$response->send();
}
}
15 changes: 9 additions & 6 deletions views/default/admin/upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
'id' => 'elgg-upgrades-run',
'link_class' => 'elgg-button elgg-button-action',
]);

echo elgg_view_entity_list($upgrades, [
'limit' => false,
'pagination' => false,
'no_results' => elgg_echo('admin:upgrades:none'),
]);

// make sure to use the same options as in \Elgg\UpgradeService::executeUpgrade()
echo elgg_call(ELGG_IGNORE_ACCESS | ELGG_SHOW_DISABLED_ENTITIES, function () use ($upgrades) {
return elgg_view_entity_list($upgrades, [
'limit' => false,
'pagination' => false,
'no_results' => elgg_echo('admin:upgrades:none'),
]);
});
17 changes: 10 additions & 7 deletions views/default/admin/upgrades/finished.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

$items = array_slice($upgrades, $offset, $limit);

echo elgg_view_entity_list($items, [
'offset' => $offset,
'limit' => $limit,
'count' => $count,
'pagination_behaviour' => 'ajax-replace',
'no_results' => true,
]);
// make sure to use the same options as in \Elgg\UpgradeService::executeUpgrade()
echo elgg_call(ELGG_IGNORE_ACCESS | ELGG_SHOW_DISABLED_ENTITIES, function() use ($items, $offset, $limit, $count) {
return elgg_view_entity_list($items, [
'offset' => $offset,
'limit' => $limit,
'count' => $count,
'pagination_behaviour' => 'ajax-replace',
'no_results' => true,
]);
});

0 comments on commit 035a403

Please sign in to comment.