<?php

namespace common\logic\Feature\FeatureProducer;

use common\logic\AbstractRepository;
use common\logic\Feature\Feature\Feature;

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();
    }
}