MediaWiki  master
CompoundAuthorizer.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
15 
17  private $authorizers;
18 
22  public function __construct( array $authorizers = [] ) {
23  $this->authorizers = $authorizers;
24  }
25 
31  public function addAuthorizer( BasicAuthorizerInterface $authorizer ): CompoundAuthorizer {
32  array_push( $this->authorizers, $authorizer );
33  return $this;
34  }
35 
42  public function authorize( RequestInterface $request, Handler $handler ) {
43  foreach ( $this->authorizers as $authorizer ) {
44  $result = $authorizer->authorize( $request, $handler );
45  if ( $result ) {
46  return $result;
47  }
48  }
49  return null;
50  }
51 }
MediaWiki\Rest\Handler
Definition: AbstractContributionHandler.php:3
MediaWiki\Rest\BasicAccess
Definition: BasicAuthorizerBase.php:3
MediaWiki\Rest\BasicAccess\CompoundAuthorizer\addAuthorizer
addAuthorizer(BasicAuthorizerInterface $authorizer)
Adds a BasicAuthorizerInterface to the chain of authorizers.
Definition: CompoundAuthorizer.php:31
MediaWiki\Rest\Handler
Base class for REST route handlers.
Definition: Handler.php:17
MediaWiki\Rest\BasicAccess\CompoundAuthorizer\$authorizers
BasicAuthorizerInterface[] $authorizers
Definition: CompoundAuthorizer.php:17
MediaWiki\Rest\RequestInterface
A request interface similar to PSR-7's ServerRequestInterface.
Definition: RequestInterface.php:39
MediaWiki\Rest\BasicAccess\CompoundAuthorizer\__construct
__construct(array $authorizers=[])
Definition: CompoundAuthorizer.php:22
MediaWiki\Rest\BasicAccess\BasicAuthorizerInterface
An interface used by Router to ensure that the client has "basic" access, i.e.
Definition: BasicAuthorizerInterface.php:14
MediaWiki\Rest\BasicAccess\CompoundAuthorizer
Definition: CompoundAuthorizer.php:14
MediaWiki\Rest\BasicAccess\CompoundAuthorizer\authorize
authorize(RequestInterface $request, Handler $handler)
Checks all registered authorizers and returns the first encountered error.
Definition: CompoundAuthorizer.php:42