mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-20 17:49:20 +02:00
* refactor(api): prefer composition to strict inheritance for API queries, requests & actions * style: fix StyleCI findigns
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Api\Field\Wiki\Video\Script;
|
|
|
|
use App\Http\Api\Field\Base\IdField;
|
|
use App\Http\Api\Query\Query;
|
|
use App\Http\Api\Schema\Schema;
|
|
use App\Models\Wiki\Video\VideoScript;
|
|
|
|
/**
|
|
* Class ScriptIdField.
|
|
*/
|
|
class ScriptIdField extends IdField
|
|
{
|
|
/**
|
|
* Create a new field instance.
|
|
*
|
|
* @param Schema $schema
|
|
*/
|
|
public function __construct(Schema $schema)
|
|
{
|
|
parent::__construct($schema, VideoScript::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 ScriptLinkField($this->schema);
|
|
if (
|
|
$this->schema->type() === $schema->type()
|
|
&& ($includeCriteria === null || $includeCriteria->getPaths()->isEmpty())
|
|
) {
|
|
return parent::shouldSelect($query, $schema) || $linkField->shouldRender($query);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|