|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of Pucene. |
| 5 | + * |
| 6 | + * (c) asapo.at |
| 7 | + * |
| 8 | + * This source file is subject to the MIT license that is bundled |
| 9 | + * with this source code in the file LICENSE. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Pucene\SealAdapter; |
| 13 | + |
| 14 | +use Pucene\Index\Driver\DriverFactoryInterface; |
| 15 | +use Pucene\Index\PuceneIndexFactory; |
| 16 | +use Schranz\Search\SEAL\Adapter\AdapterInterface; |
| 17 | +use Schranz\Search\SEAL\Adapter\ConnectionInterface; |
| 18 | +use Schranz\Search\SEAL\Adapter\SchemaManagerInterface; |
| 19 | + |
| 20 | +class PuceneAdapter implements AdapterInterface |
| 21 | +{ |
| 22 | + public static function createFromFactories( |
| 23 | + PuceneIndexFactory $indexFactory, |
| 24 | + DriverFactoryInterface $driverFactory, |
| 25 | + ): self { |
| 26 | + return new self( |
| 27 | + new PuceneConnection($indexFactory), |
| 28 | + new PuceneSchemaManager($driverFactory), |
| 29 | + ); |
| 30 | + } |
| 31 | + |
| 32 | + private readonly ConnectionInterface $connection; |
| 33 | + |
| 34 | + private readonly SchemaManagerInterface $schemaManager; |
| 35 | + |
| 36 | + public function __construct( |
| 37 | + ConnectionInterface $connection, |
| 38 | + SchemaManagerInterface $schemaManager, |
| 39 | + ) { |
| 40 | + $this->connection = $connection; |
| 41 | + $this->schemaManager = $schemaManager; |
| 42 | + } |
| 43 | + |
| 44 | + public function getSchemaManager(): SchemaManagerInterface |
| 45 | + { |
| 46 | + return $this->schemaManager; |
| 47 | + } |
| 48 | + |
| 49 | + public function getConnection(): ConnectionInterface |
| 50 | + { |
| 51 | + return $this->connection; |
| 52 | + } |
| 53 | +} |
0 commit comments