Applied API role specs to global visits

This commit is contained in:
Alejandro Celaya
2021-01-04 11:27:55 +01:00
parent 8aa6bdb934
commit 68c601a5a8
9 changed files with 34 additions and 12 deletions

View File

@@ -12,17 +12,19 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class WithApiKeySpecsEnsuringJoin extends BaseSpecification
{
private ?ApiKey $apiKey;
private string $fieldToJoin;
public function __construct(?ApiKey $apiKey)
public function __construct(?ApiKey $apiKey, string $fieldToJoin)
{
parent::__construct();
$this->apiKey = $apiKey;
$this->fieldToJoin = $fieldToJoin;
}
protected function getSpec(): Specification
{
return $this->apiKey === null || $this->apiKey->isAdmin() ? Spec::andX() : Spec::andX(
Spec::join('shortUrls', 's'),
Spec::join($this->fieldToJoin, 's'),
$this->apiKey->spec(),
);
}