Created some twig extensions for checking membership using the new authorization manager callbacks

This commit is contained in:
2022-02-10 12:56:18 +00:00
parent 99add37bdd
commit fade1f8441
2 changed files with 88 additions and 1 deletions

View File

@@ -13,9 +13,11 @@ use Illuminate\Database\Capsule\Manager as Capsule;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use UserFrosting\Sprinkle\Organisations\Database\Models\Interfaces\OrganisationInterface as OrganisationInterface;
use UserFrosting\Sprinkle\Organisations\Database\Models\Interfaces\OrganisationInterface;
use UserFrosting\Sprinkle\Organisations\Twig\OrganisationsExtension;
use UserFrosting\Sprinkle\Organisations\Authorize\AuthorizationManager;
/**
* Registers services for the organisation sprinkle.
*
@@ -87,6 +89,19 @@ class ServicesProvider
return $new_authorizer;
});
/*
* Extends the 'view' service with the OrganisationsExtension for Twig.
*
* @return \Slim\Views\Twig
*/
$container->extend('view', function ($view, $c) {
$twig = $view->getEnvironment();
$extension = new OrganisationsExtension($c);
$twig->addExtension($extension);
return $view;
});
/*
* Returns a callback that handles merging any organisation objects.
*