Standardized how inlined or regular specs are applied to query builders

This commit is contained in:
Alejandro Celaya
2022-01-18 20:06:32 +01:00
parent d39f3b4265
commit 9e9621e7b2
6 changed files with 61 additions and 59 deletions

View File

@@ -11,8 +11,11 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class WithApiKeySpecsEnsuringJoin extends BaseSpecification
{
public function __construct(private ?ApiKey $apiKey, private string $fieldToJoin = 'shortUrls')
{
public function __construct(
private ?ApiKey $apiKey,
private string $fieldToJoin = 'shortUrls',
private bool $inlined = false,
) {
parent::__construct();
}
@@ -20,7 +23,7 @@ class WithApiKeySpecsEnsuringJoin extends BaseSpecification
{
return $this->apiKey === null || $this->apiKey->isAdmin() ? Spec::andX() : Spec::andX(
Spec::join($this->fieldToJoin, 's'),
$this->apiKey->spec(false, $this->fieldToJoin),
$this->inlined ? $this->apiKey->inlinedSpec() : $this->apiKey->spec($this->fieldToJoin),
);
}
}