mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-08 01:18:48 +00:00
[advancedcontentfilter] Migrate Slim to version 4 to avoid PHP 8.2 deprecation error
- Fix https://github.com/friendica/friendica/issues/13822
This commit is contained in:
parent
b05a95cc45
commit
a30e9b788c
376 changed files with 10144 additions and 15497 deletions
|
@ -21,31 +21,12 @@
|
|||
|
||||
use Friendica\DI;
|
||||
|
||||
$container = $slim->getContainer();
|
||||
/** @var $slim \Slim\App */
|
||||
|
||||
// Error handler based off https://stackoverflow.com/a/48135009/757392
|
||||
$container['errorHandler'] = function () {
|
||||
return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
|
||||
{
|
||||
$responseCode = 500;
|
||||
/**
|
||||
* The routing middleware should be added before the ErrorMiddleware
|
||||
* Otherwise exceptions thrown from it will not be handled
|
||||
*/
|
||||
$slim->addRoutingMiddleware();
|
||||
|
||||
if (is_a($exception, 'Friendica\Network\HTTPException')) {
|
||||
$responseCode = $exception->getCode();
|
||||
}
|
||||
|
||||
$errors['message'] = $exception->getMessage();
|
||||
|
||||
$errors['responseCode'] = $responseCode;
|
||||
|
||||
return $response
|
||||
->withStatus($responseCode)
|
||||
->withJson($errors);
|
||||
};
|
||||
};
|
||||
|
||||
$container['notFoundHandler'] = function () {
|
||||
return function ()
|
||||
{
|
||||
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Method not found'));
|
||||
};
|
||||
};
|
||||
$errorMiddleware = $slim->addErrorMiddleware(true, true, true);
|
||||
|
|
|
@ -20,20 +20,17 @@
|
|||
*/
|
||||
|
||||
/* @var $slim Slim\App */
|
||||
$slim->group('/advancedcontentfilter/api', function () {
|
||||
/* @var $this Slim\App */
|
||||
$this->group('/rules', function () {
|
||||
/* @var $this Slim\App */
|
||||
$this->get('', 'advancedcontentfilter_get_rules');
|
||||
$this->post('', 'advancedcontentfilter_post_rules');
|
||||
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('', 'advancedcontentfilter_get_rules');
|
||||
$app->post('', 'advancedcontentfilter_post_rules');
|
||||
|
||||
$this->get('/{id}', 'advancedcontentfilter_get_rules_id');
|
||||
$this->put('/{id}', 'advancedcontentfilter_put_rules_id');
|
||||
$this->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
|
||||
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
|
||||
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
|
||||
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
|
||||
});
|
||||
|
||||
$this->group('/variables', function () {
|
||||
/* @var $this Slim\App */
|
||||
$this->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
|
||||
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue