mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-19 01:01:04 +02:00
* refactor(api): prefer composition to strict inheritance for API queries, requests & actions * style: fix StyleCI findigns
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Api\Field\Admin\Dump;
|
|
|
|
use App\Http\Api\Field\Base\IdField;
|
|
use App\Http\Api\Query\Query;
|
|
use App\Http\Api\Schema\Schema;
|
|
use App\Models\Admin\Dump;
|
|
|
|
/**
|
|
* Class DumpIdField.
|
|
*/
|
|
class DumpIdField extends IdField
|
|
{
|
|
/**
|
|
* Create a new field instance.
|
|
*
|
|
* @param Schema $schema
|
|
*/
|
|
public function __construct(Schema $schema)
|
|
{
|
|
parent::__construct($schema, Dump::ATTRIBUTE_ID);
|
|
}
|
|
|
|
/**
|
|
* Determine if the field should be included in the select clause of our query.
|
|
*
|
|
* @param Query $query
|
|
* @param Schema $schema
|
|
* @return bool
|
|
*/
|
|
public function shouldSelect(Query $query, Schema $schema): bool
|
|
{
|
|
$includeCriteria = $query->getIncludeCriteria($this->schema->type());
|
|
$linkField = new DumpLinkField($this->schema);
|
|
if (
|
|
$this->schema->type() === $schema->type()
|
|
&& ($includeCriteria === null || $includeCriteria->getPaths()->isEmpty())
|
|
) {
|
|
return parent::shouldSelect($query, $schema) || $linkField->shouldRender($query);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|