Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(api): Combining type & search bar doesn't work #8427

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/Centreon/Infrastructure/Monitoring/ResourceRepositoryRDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,27 @@ public function findResources(ResourceFilter $filter): array
*
* @return bool
*/
private function hasServiceSearch()
private function hasServiceSearch(): bool
{
return $this->extractSpecificSearchCriteria('/^service\./')
&& !$this->extractSpecificSearchCriteria('/^host\./');
}

/**
* Extract request parameters
*
* @param string $key
* @return bool
*/
private function extractSpecificSearchCriteria(string $key)
{
$requestParameters = $this->sqlRequestTranslator->getRequestParameters();
$search = $requestParameters->getSearch();

$serviceConcordances = array_reduce(
array_keys($this->serviceConcordances),
function ($acc, $concordanceKey) {
if (preg_match('/^service\./', $concordanceKey)) {
function ($acc, $concordanceKey) use ($key) {
if (preg_match($key, $concordanceKey)) {
$acc[] = $concordanceKey;
}
return $acc;
Expand Down