Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basic VIP Enterprise Search Adapter #8

Merged
merged 13 commits into from
Apr 28, 2022
Prev Previous commit
Next Next commit
Allow chaining in adapter methods, move adapters to lib
  • Loading branch information
kevinfodness committed Mar 29, 2022
commit e7dab62bfe855c5695d48ac47c1d7bc72826bcb8
18 changes: 15 additions & 3 deletions adapters/class-adapter.php → lib/adapters/class-adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,26 @@ abstract class Adapter {

/**
* Enables an aggregation based on post type.
*
* @return Adapter The instance of the class to allow for chaining.
*/
public function enable_post_type_aggregation(): void {
public function enable_post_type_aggregation(): Adapter {
$this->aggregate_post_types = true;

return $this;
}

/**
* A function to enable an aggregation for a specific taxonomy.
*
* @param string $taxonomy The taxonomy slug for which to enable an aggregation.
*
* @return Adapter The instance of the class to allow for chaining.
*/
public function enable_taxonomy_aggregation( string $taxonomy ): void {
public function enable_taxonomy_aggregation( string $taxonomy ): Adapter {
$this->aggregate_taxonomies[] = $taxonomy;

return $this;
}

/**
Expand Down Expand Up @@ -104,9 +112,13 @@ public static function instance(): Adapter {
* Sets aggregation results.
*
* @param array $aggregations An array of aggregation results to be stored.
*
* @return Adapter The instance of the class to allow for chaining.
*/
protected function set_aggregations( array $aggregations ): void {
protected function set_aggregations( array $aggregations ): Adapter {
$this->aggregations = $aggregations;

return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function autoload( string $class ) {
$dirs = explode( '\\', $class );
$class = array_pop( $dirs );

require_once dirname( __DIR__ ) . '/' . implode( '/', $dirs ) . '/class-' . $class . '.php';
require_once __DIR__ . '/' . implode( '/', $dirs ) . '/class-' . $class . '.php';
}

spl_autoload_register( '\Elasticsearch_Extensions\autoload' );