TeamTNT\TNTSearch\Indexer\TNTIndexer::readDocumentsFromFileSystem PHP Méthode

readDocumentsFromFileSystem() public méthode

    public function readDocumentsFromFileSystem()
    {
        $exclude = [];
        if (isset($this->config['exclude'])) {
            $exclude = $this->config['exclude'];
        }
        $this->index->exec("CREATE TABLE IF NOT EXISTS filemap (\n                    id INTEGER PRIMARY KEY,\n                    path TEXT)");
        $path = realpath($this->config['location']);
        $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
        $this->index->beginTransaction();
        $counter = 0;
        foreach ($objects as $name => $object) {
            $name = str_replace($path . '/', '', $name);
            if (stringEndsWith($name, $this->config['extension']) && !in_array($name, $exclude)) {
                $counter++;
                $file = ['id' => $counter, 'name' => $name, 'content' => $this->filereader->read($object)];
                $this->processDocument(new Collection($file));
                $this->index->exec("INSERT INTO filemap ( 'id', 'path') values ( {$counter}, '{$object}')");
                $this->info("Processed {$counter} {$object}");
            }
        }
        $this->index->commit();
        $this->index->exec("INSERT INTO info ( 'key', 'value') values ( 'total_documents', {$counter})");
        $this->index->exec("INSERT INTO info ( 'key', 'value') values ( 'driver', 'filesystem')");
        $this->info("Total rows {$counter}");
        $this->info("Index created: {$this->config['storage']}");
    }