Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ConsumerPluginBase | |
80.00% |
4 / 5 |
|
50.00% |
1 / 2 |
3.07 | |
0.00% |
0 / 1 |
| consumerTargetCreationAllowed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| filterProposals | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\authorization\Consumer; |
| 6 | |
| 7 | use Drupal\authorization\Plugin\ConfigurableAuthorizationPluginBase; |
| 8 | |
| 9 | /** |
| 10 | * Base class for Authorization consumer plugins. |
| 11 | */ |
| 12 | abstract class ConsumerPluginBase extends ConfigurableAuthorizationPluginBase implements ConsumerInterface { |
| 13 | |
| 14 | /** |
| 15 | * Defines the type, for example used by getToken(). |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | protected $type = 'consumer'; |
| 20 | |
| 21 | /** |
| 22 | * Whether this plugins supports consumer target creation. |
| 23 | * |
| 24 | * @var bool |
| 25 | */ |
| 26 | protected $allowConsumerTargetCreation = FALSE; |
| 27 | |
| 28 | /** |
| 29 | * {@inheritdoc} |
| 30 | */ |
| 31 | public function consumerTargetCreationAllowed(): bool { |
| 32 | return $this->allowConsumerTargetCreation; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * {@inheritdoc} |
| 37 | */ |
| 38 | public function filterProposals(array $proposals, array $mapping): array { |
| 39 | if (!empty($proposals)) { |
| 40 | $property = array_pop($mapping); |
| 41 | return [$property => $property]; |
| 42 | } |
| 43 | |
| 44 | return []; |
| 45 | } |
| 46 | |
| 47 | } |