/** * Runs index by file. * @param File $file Target file. * @throws \Bitrix\Main\ArgumentNullException * @throws \Bitrix\Main\LoaderException * @return void */ public function indexFile(File $file) { if (!Loader::includeModule('search')) { return; } //here we place configuration by Module (Options). Example, we can deactivate index for big files in Disk. if (!Configuration::allowIndexFiles()) { return; } $storage = $file->getStorage(); if (!$storage) { return; } if (!$storage->getProxyType()->canIndexBySearch()) { return; } $searchData = array('LAST_MODIFIED' => $file->getUpdateTime() ?: $file->getCreateTime(), 'TITLE' => $file->getName(), 'PARAM1' => $file->getStorageId(), 'PARAM2' => $file->getParentId(), 'SITE_ID' => $storage->getSiteId() ?: SITE_ID, 'URL' => $this->getDetailUrl($file), 'PERMISSIONS' => $this->getSimpleRights($file), 'BODY' => $this->getFileContent($file)); if ($storage->getProxyType() instanceof Group) { $searchData['PARAMS'] = array('socnet_group' => $storage->getEntityId(), 'entity' => 'socnet_group'); } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ CSearch::index(Driver::INTERNAL_MODULE_ID, $this->getItemId($file), $searchData, true); }