. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Core\Select\Primary; use Espo\Core\Exceptions\BadRequest; use Espo\Core\Select\SelectManager; use Espo\Core\Select\OrmSelectBuilder; use Espo\ORM\Query\SelectBuilder; use Espo\Entities\User; class Applier { public function __construct( private string $entityType, private User $user, private FilterFactory $primaryFilterFactory, private SelectManager $selectManager ) {} /** * @throws BadRequest */ public function apply(SelectBuilder $queryBuilder, string $filterName): void { if ($this->primaryFilterFactory->has($this->entityType, $filterName)) { $filter = $this->primaryFilterFactory->create($this->entityType, $this->user, $filterName); $filter->apply($queryBuilder); return; } // For backward compatibility. if ( $this->selectManager->hasPrimaryFilter($filterName) && $queryBuilder instanceof OrmSelectBuilder ) { $this->selectManager->applyPrimaryFilterToQueryBuilder($queryBuilder, $filterName); return; } throw new BadRequest("No primary filter '$filterName' for '$this->entityType'."); } }