- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/controller/action/entity/searchaction.php
- Класс: Bitrix\Crm\Controller\Action\Entity\SearchAction
- Вызов: SearchAction::provideData
public function provideData($searchQuery, array $options = null, PageNavigation $pageNavigation = null)
{
if (!is_array($options))
{
$options = [];
}
$entityTypeIds = $this->prepareSearchEntityTypeIds($options);
$scope = isset($options['scope'])
? EntitySearchScope::resolveID($options['scope'])
: EntitySearchScope::UNDEFINED;
if ($scope === EntitySearchScope::UNDEFINED)
{
$scope = EntitySearchScope::DENOMINATION;
}
$searchRestriction = RestrictionManager::getSearchLimitRestriction();
$this->limit = static::LIMIT;
$results = [];
foreach ($entityTypeIds as $entityTypeId)
{
if (
!$searchRestriction->isExceeded($entityTypeId)
&& $this->limit > 0
)
{
if (
\CCrmOwnerType::isUseDynamicTypeBasedApproach($entityTypeId)
&& !Container::getInstance()->getTypeByEntityTypeId($entityTypeId)
)
{
continue;
}
$searchResultProvider = Factory::createProvider($entityTypeId);
$searchResultProvider->setUserId($this->userId);
$searchResultProvider->setLimit($this->limit);
$searchResultProvider->setUseDenominationSearch($scope !== EntitySearchScope::INDEX);
$searchResultProvider->setAdditionalFilter($this->getAdditionalFilter($entityTypeId, $options));
$searchResultProvider->setAffectedCategories($this->getAffectedCategoriesFromOptions($options));
if ($this->isMyCompanyFromOptions($options) && Container::getInstance()->getUserPermissions()->getMyCompanyPermissions()->canSearch())
{
$searchResultProvider->setCheckPermissions(false);
}
$searchResult = $searchResultProvider->getSearchResult($searchQuery);
$categoryId = $options['categoryId'] ?? 0;
$adapter = Factory::createResultAdapter($entityTypeId, $categoryId);
self::applyCategoryLabelsToAdapter($adapter, (int)$entityTypeId, $options);
$results = array_merge(
$results,
$adapter->adapt($searchResult)
);
$this->limit = static::LIMIT - count($results);
}
}
return $results;
}