Skip to content

Commit

Permalink
Merge pull request teamtnt#152 from Connum/indexer-extension-array-or…
Browse files Browse the repository at this point in the history
…-callable

feature: TNTIndexer 'extension' option as array or callable
  • Loading branch information
nticaric authored Jun 4, 2018
2 parents 5e25eec + e7253f3 commit 519d06b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Indexer/TNTIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,16 @@ public function readDocumentsFromFileSystem()

foreach ($objects as $name => $object) {
$name = str_replace($path.'/', '', $name);
if (stringEndsWith($name, $this->config['extension']) && !in_array($name, $exclude)) {

if (is_callable($this->config['extension'])) {
$includeFile = $this->config['extension']($object);
} elseif (is_array($this->config['extension'])) {
$includeFile = in_array($object->getExtension(), $this->config['extension']);
} else {
$includeFile = stringEndsWith($name, $this->config['extension']);
}

if ($includeFile && !in_array($name, $exclude)) {
$counter++;
$file = [
'id' => $counter,
Expand Down

0 comments on commit 519d06b

Please sign in to comment.