Loading search_api_attachments.api.php +35 Changes for search_api_attachments.api.php: 35 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Hooks provided by the "Search API attachments" module. */ /** * @addtogroup hooks * @{ */ /** * Determines whether an attachment should be indexed. * * @param object $file * A file object. * @param \Drupal\search_api\Item\ItemInterface $item * The item the file was referenced in. * @param string $field_name * The name of the field the file was referenced in. * * @return bool|null * Return FALSE if the attachment should not be indexed. */ function hook_search_api_attachments_indexable($file, $item, $field_name) { // Don't index files on entities owned by our bulk upload bot accounts. if (in_array($item->getOriginalObject()->uid, my_module_blocked_uids())) { return FALSE; } } /** * @} End of "addtogroup hooks". */ No newline at end of file src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php +11 −2 Changes for src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { ->loadMultiple($fids); $extraction = ''; foreach ($files as $file) { if ($this->isFileIndexable($file)) { if ($this->isFileIndexable($file, $item, $field_name)) { $extraction .= $this->extractOrGetFromCache($file, $extractor_plugin); } } Loading Loading @@ -189,11 +189,15 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { * * @param object $file * A file object. * @param \Drupal\search_api\Item\ItemInterface $item * The item the file was referenced in. * @param string|null $field_name * The name of the field the file was referenced in, if applicable. * * @return bool * TRUE or FALSE */ public function isFileIndexable($file) { public function isFileIndexable($file, $item, $field_name = NULL) { // File should exist in disc. $indexable = file_exists($file->getFileUri()); if (!$indexable) { Loading @@ -216,6 +220,11 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { } // Whether a private file can be indexed or not. $indexable = $indexable && $this->isPrivateFileAllowed($file); if (!$indexable) { return FALSE; } $result = \Drupal::moduleHandler()->invokeAll('search_api_attachments_indexable', $file, $item, $field_name); $indexable = !in_array(FALSE, $result, TRUE); return $indexable; } Loading Loading
search_api_attachments.api.php +35 Changes for search_api_attachments.api.php: 35 added lines, 0 removed lines. Original line number Diff line number Diff line <?php /** * @file * Hooks provided by the "Search API attachments" module. */ /** * @addtogroup hooks * @{ */ /** * Determines whether an attachment should be indexed. * * @param object $file * A file object. * @param \Drupal\search_api\Item\ItemInterface $item * The item the file was referenced in. * @param string $field_name * The name of the field the file was referenced in. * * @return bool|null * Return FALSE if the attachment should not be indexed. */ function hook_search_api_attachments_indexable($file, $item, $field_name) { // Don't index files on entities owned by our bulk upload bot accounts. if (in_array($item->getOriginalObject()->uid, my_module_blocked_uids())) { return FALSE; } } /** * @} End of "addtogroup hooks". */ No newline at end of file
src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php +11 −2 Changes for src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { ->loadMultiple($fids); $extraction = ''; foreach ($files as $file) { if ($this->isFileIndexable($file)) { if ($this->isFileIndexable($file, $item, $field_name)) { $extraction .= $this->extractOrGetFromCache($file, $extractor_plugin); } } Loading Loading @@ -189,11 +189,15 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { * * @param object $file * A file object. * @param \Drupal\search_api\Item\ItemInterface $item * The item the file was referenced in. * @param string|null $field_name * The name of the field the file was referenced in, if applicable. * * @return bool * TRUE or FALSE */ public function isFileIndexable($file) { public function isFileIndexable($file, $item, $field_name = NULL) { // File should exist in disc. $indexable = file_exists($file->getFileUri()); if (!$indexable) { Loading @@ -216,6 +220,11 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { } // Whether a private file can be indexed or not. $indexable = $indexable && $this->isPrivateFileAllowed($file); if (!$indexable) { return FALSE; } $result = \Drupal::moduleHandler()->invokeAll('search_api_attachments_indexable', $file, $item, $field_name); $indexable = !in_array(FALSE, $result, TRUE); return $indexable; } Loading