ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Searcher.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
30 
31 class Searcher implements SearcherInterface
32 {
34  protected FilterFactory $filter_factory;
36 
37  public function __construct(
38  ClauseFactory $clause_factory,
39  FilterFactory $filter_factory,
40  RepositoryInterface $repository
41  ) {
42  $this->clause_factory = $clause_factory;
43  $this->filter_factory = $filter_factory;
44  $this->repository = $repository;
45  }
46 
47  public function getClauseFactory(): ClauseFactory
48  {
49  return $this->clause_factory;
50  }
51 
52  public function getFilter(
53  int|Placeholder $obj_id = Placeholder::ANY,
54  int|Placeholder $sub_id = Placeholder::ANY,
55  string|Placeholder $type = Placeholder::ANY
56  ): FilterInterface {
57  if ($sub_id === 0) {
58  $sub_id = Placeholder::OBJ_ID;
59  }
60  return $this->filter_factory->get($obj_id, $sub_id, $type);
61  }
62 
66  public function execute(
67  ClauseInterface $clause,
68  ?int $limit,
69  ?int $offset,
70  FilterInterface ...$filters
71  ): \Generator {
72  yield from $this->repository->searchMD(
73  $clause,
74  $limit,
75  $offset,
76  ...$filters
77  );
78  }
79 }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
getFilter(int|Placeholder $obj_id=Placeholder::ANY, int|Placeholder $sub_id=Placeholder::ANY, string|Placeholder $type=Placeholder::ANY)
Get a filter with which the results of a search can be restricted.
Definition: Searcher.php:52
__construct(ClauseFactory $clause_factory, FilterFactory $filter_factory, RepositoryInterface $repository)
Definition: Searcher.php:37
getClauseFactory()
Get a factory where you can assemble your search clause.
Definition: Searcher.php:47
execute(ClauseInterface $clause, ?int $limit, ?int $offset, FilterInterface ... $filters)
Definition: Searcher.php:66