<?php

namespace domain\Feature\FeatureProducer;

use domain\Feature\Feature\Feature;
use domain\_\AbstractRepository;

class FeatureProducerRepository extends AbstractRepository
{
    protected FeatureProducerRepositoryQuery $query;

    public function loadDependencies(): void
    {
        $this->loadQuery(FeatureProducerRepositoryQuery::class);
    }

    public function getDefaultOptionsSearch(): array
    {
        return [
            self::WITH => ['feature', 'producer'],
            self::JOIN_WITH => [],
            self::ORDER_BY => '',
            self::ATTRIBUTE_ID_PRODUCER => 'feature_producer.id_producer'
        ];
    }

    public function findOneFeatureProducer(Feature $feature)
    {
        return $this->createDefaultQuery()
            ->filterByFeature($feature)
            ->findOne();
    }
}