Elgg  Version master
Public Member Functions | List of all members
Elgg\Gatekeeper Class Reference

Gatekeeper. More...

Public Member Functions

 __construct (protected SessionManagerService $session_manager, protected HttpRequest $request, protected RedirectService $redirects, protected EntityTable $entities, protected AccessCollections $access, protected Translator $translator, protected PageOwnerService $page_owner)
 Constructor. More...
 
 assertAuthenticatedUser ()
 Require a user to be authenticated to with code execution. More...
 
 assertUnauthenticatedUser ()
 Require a user to be not authenticated (logged out) to with code execution. More...
 
 assertAuthenticatedAdmin ()
 Require an admin user to be authenticated to proceed with code execution. More...
 
 assertExists (int $guid, ?string $type=null, ?string $subtype=null)
 Require an entity with a given guid, type and subtype to proceed with code execution. More...
 
 assertAccessibleEntity (\ElggEntity $entity, ?\ElggUser $user=null, bool $validate_can_edit=false)
 Require that authenticated user has access to entity. More...
 
 assertAccessibleUser (\ElggUser $user, ?\ElggUser $viewer=null)
 Validate active user account. More...
 
 assertAccessibleGroup (\ElggGroup $group, ?\ElggUser $user=null)
 Validate group content visibility. More...
 
 assertGroupToolEnabled (string $group_tool, ?\ElggGroup $group=null)
 Validate group tool enabled. More...
 
 assertXmlHttpRequest ()
 Require XmlHttpRequest. More...
 

Detailed Description

Gatekeeper.

Use elgg()->gatekeeper

Definition at line 26 of file Gatekeeper.php.

Constructor & Destructor Documentation

◆ __construct()

Elgg\Gatekeeper::__construct ( protected SessionManagerService  $session_manager,
protected HttpRequest  $request,
protected RedirectService  $redirects,
protected EntityTable  $entities,
protected AccessCollections  $access,
protected Translator  $translator,
protected PageOwnerService  $page_owner 
)

Constructor.

Parameters
SessionManagerService$session_managerSession manager
HttpRequest$requestHTTP Request
RedirectService$redirectsRedirects Service
EntityTable$entitiesEntity table
AccessCollections$accessAccess collection table
Translator$translatorTranslator
PageOwnerService$page_ownerPage owner service

Definition at line 39 of file Gatekeeper.php.

Member Function Documentation

◆ assertAccessibleEntity()

Elgg\Gatekeeper::assertAccessibleEntity ( \ElggEntity  $entity,
?\ElggUser  $user = null,
bool  $validate_can_edit = false 
)

Require that authenticated user has access to entity.

Parameters
\ElggEntity$entityEntity
\ElggUser | null$userUser
bool$validate_can_editflag to check canEdit access
Returns
void
Exceptions
HttpException

Definition at line 145 of file Gatekeeper.php.

◆ assertAccessibleGroup()

Elgg\Gatekeeper::assertAccessibleGroup ( \ElggGroup  $group,
?\ElggUser  $user = null 
)

Validate group content visibility.

Parameters
\ElggGroup$groupGroup entity
\ElggUser | null$userUser entity
Returns
void
Exceptions
GroupGatekeeperException
GatekeeperException

Definition at line 256 of file Gatekeeper.php.

◆ assertAccessibleUser()

Elgg\Gatekeeper::assertAccessibleUser ( \ElggUser  $user,
?\ElggUser  $viewer = null 
)

Validate active user account.

Parameters
\ElggUser$userUser
\ElggUser | null$viewerViewing user
Returns
void
Exceptions
EntityNotFoundException

Definition at line 226 of file Gatekeeper.php.

◆ assertAuthenticatedAdmin()

Elgg\Gatekeeper::assertAuthenticatedAdmin ( )

Require an admin user to be authenticated to proceed with code execution.

Returns
void
Exceptions
GatekeeperException
AdminGatekeeperException

Definition at line 90 of file Gatekeeper.php.

◆ assertAuthenticatedUser()

Elgg\Gatekeeper::assertAuthenticatedUser ( )

Require a user to be authenticated to with code execution.

Returns
void
Exceptions
LoggedInGatekeeperException

Definition at line 56 of file Gatekeeper.php.

◆ assertExists()

Elgg\Gatekeeper::assertExists ( int  $guid,
?string  $type = null,
?string  $subtype = null 
)

Require an entity with a given guid, type and subtype to proceed with code execution.

Warning
Returned entity has been retrieved with ignored access, as well including disabled entities. You must validate entity access on the return of this method.
Parameters
int$guidGUID of the entity
string | null$typeEntity type
string | null$subtypeEntity subtype
Returns
\ElggEntity
Exceptions
EntityNotFoundException

Definition at line 116 of file Gatekeeper.php.

◆ assertGroupToolEnabled()

Elgg\Gatekeeper::assertGroupToolEnabled ( string  $group_tool,
?\ElggGroup  $group = null 
)

Validate group tool enabled.

Parameters
string$group_toolthe group tool to check
\ElggGroup | null$groupthe group to check on (default: page owner)
Returns
void
Exceptions
GroupToolGatekeeperException
HttpException

Definition at line 285 of file Gatekeeper.php.

◆ assertUnauthenticatedUser()

Elgg\Gatekeeper::assertUnauthenticatedUser ( )

Require a user to be not authenticated (logged out) to with code execution.

Returns
void
Exceptions
LoggedOutGatekeeperException

Definition at line 72 of file Gatekeeper.php.

◆ assertXmlHttpRequest()

Elgg\Gatekeeper::assertXmlHttpRequest ( )

Require XmlHttpRequest.

Returns
void
Exceptions
AjaxGatekeeperException

Definition at line 311 of file Gatekeeper.php.


The documentation for this class was generated from the following file: