<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Utils\FilterSettings\Dozenten;

use Kufer\Web\Classes\Dbfilter\DozentenSQLFilter;
use Kufer\Web\KuferTools\Utils\FilterSettings\IFilterSettings;
use Kufer\Web\Classes\Dbfilter\ISQLFilter;


class HasBeziehungWithFirmaFilterSettings implements IFilterSettings
{
  
  protected $user;

  public function __construct(\Benutzer $user)
  {
    $this->user = $user;
  }

  
  public function applySettings($filter): ISQLFilter
  {
    $bezFilter = \Kufer\Web\Classes\Dbfilter\BeziehungenSQLFilter::create()
      ->equalsTyp1('T')
      ->equalsTyp2('D')
      ->equalsReferenz1($this->user->getTnrIdentifier());

    return $filter->applyBeziehungenFilterReferenz2($bezFilter);
  }

  public function assertFilterClass($filter): void
  {
    assert($filter instanceof DozentenSQLFilter);
  }
}