feat: new Discover section shows watch providers for results
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Base\Enum\MediaType;
|
||||
use App\Tmdb\Dto\CastMemberDto;
|
||||
use App\Tmdb\Dto\CrewMemberDto;
|
||||
use App\Tmdb\Dto\GenreDto;
|
||||
use App\Tmdb\Dto\WatchProviderDto;
|
||||
use App\Tmdb\TmdbResult;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
@@ -28,6 +29,7 @@ class TmdbResultDenormalizer implements DenormalizerInterface
|
||||
$result->directors = $this->getDirectors($data);
|
||||
$result->producers = $this->getProducers($data);
|
||||
$result->creators = $this->getCreators($data);
|
||||
$result->watchProviders = $this->getWatchProviders($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -87,6 +89,17 @@ class TmdbResultDenormalizer implements DenormalizerInterface
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function getWatchProviders(array $data): ?array
|
||||
{
|
||||
if (!array_key_exists('watch/providers', $data)) {
|
||||
return null;
|
||||
}
|
||||
// ToDo: Make region configurable
|
||||
return Map::from($data['watch/providers']['results']['US']['flatrate'])
|
||||
->map(fn($item) => $this->normalizer->denormalize($item, WatchProviderDto::class))
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
|
||||
Reference in New Issue
Block a user