forked from phpDocumentor/phpDocumentor
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
phpDocumentor#636: Added EngineManager and refactored code
In this commit I cleaned up the code by adding DocBlocks and renaming the Engine namespace to Adapter in order to be more explicit in our intention with that code. In order to provide a clear entry point and extension point I added an EngineManager class, inspired on Doctrine's EntityManager, that calls the correct adapter and works as a frontend.
- Loading branch information
Showing
14 changed files
with
416 additions
and
72 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/phpDocumentor/Plugin/Search/Adapter/AdapterInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
namespace phpDocumentor\Plugin\Search\Adapter; | ||
|
||
use phpDocumentor\Plugin\Search\Document; | ||
|
||
interface AdapterInterface | ||
{ | ||
/** | ||
* Returns the adapter-specific configuration object. | ||
* | ||
* @return object | ||
*/ | ||
public function getConfiguration(); | ||
|
||
/** | ||
* Evaluates the given expression and tries to find, and return, a number of Documents equal to the amount found or | ||
* the limit if provided. | ||
* | ||
* @param string $expression A query expression used to limit the type of documents returned. | ||
* @param int $start At which point in the result set to start returning documents. | ||
* @param int $limit How many documents to return at maximum. | ||
* | ||
* @return Document[] | ||
*/ | ||
public function find($expression, $start = 0, $limit = 10); | ||
|
||
/** | ||
* Marks the given document for addition in the Search Engine so it can be found later again. | ||
* | ||
* Please note that the actual writing to the Search Engine happens once the {@see flush()} method is called. Until | ||
* then all addition and removal operations are stored in memory and unless flushed not found in the Search Engine. | ||
* | ||
* @param Document $document | ||
* | ||
* @return void | ||
*/ | ||
public function persist(Document $document); | ||
|
||
/** | ||
* Marks a document for removal so it will be removed once the flush method is called. | ||
* | ||
* Please note that the actual writing to the Search Engine happens once the {@see flush()} method is called. Until | ||
* then all addition and removal operations are stored in memory and unless flushed not found in the Search Engine. | ||
* | ||
* @param Document $document | ||
* | ||
* @return void | ||
*/ | ||
public function remove(Document $document); | ||
|
||
/** | ||
* Writes all changes to the Search Engine's data to the Search Engine. | ||
* | ||
* @return void | ||
*/ | ||
public function flush(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ch/Engine/Configuration/ElasticSearch.php → ...h/Adapter/Configuration/ElasticSearch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...in/Search/Engine/Configuration/LunrJs.php → ...n/Search/Adapter/Configuration/LunrJs.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Plugin/Search/Engine/PersistException.php → ...lugin/Search/Adapter/PersistException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/phpDocumentor/Plugin/Search/Engine/EngineInterface.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.