Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 8, 2019
1 parent 774d52e commit 85c636b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## [Unreleased (2019-xx-xx)](https://github.com/laravel/scout/compare/v6.1.3...master)

### Changed
- Upgrade Algolia API client to v2 ([#349](https://github.com/laravel/scout/pull/349), [#353](https://github.com/laravel/scout/pull/353))
- Upgraded Algolia API client to v2 ([#349](https://github.com/laravel/scout/pull/349), [#353](https://github.com/laravel/scout/pull/353))

## [v6.1.3 (2018-12-11)](https://github.com/laravel/scout/compare/v6.1.2...v6.1.3)

Expand Down
16 changes: 11 additions & 5 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@

Update your `laravel/scout` dependency to `^7.0` in your `composer.json` file.

### When using the Algolia driver
### Algolia Driver

Update your `algolia/algoliasearch-client-php` dependency to `^2.2` in your `composer.json` file.
If you are using Algolia as your search provider, update your `algolia/algoliasearch-client-php` dependency to `^2.2` in your `composer.json` file.

If you were relying on the exception `AlgoliaSearch\AlgoliaException`, you may need to adapt your code since it got renamed to `Algolia\AlgoliaSearch\Exceptions\AlgoliaException`.
#### Exception Renaming

If you were customizing engine searches giving a callback as the second argument of the method `search` in your models, the first argument of the given callback is now an instance of `Algolia\AlgoliaSearch\SearchIndex`.
The `AlgoliaSearch\AlgoliaException` exception class was renamed to `Algolia\AlgoliaSearch\Exceptions\AlgoliaException`.

If you were using the Algolia API Client source code directly, consider review the [full changelog here](https://github.com/algolia/algoliasearch-client-php/blob/master/docs/UPGRADE-from-v1-to-v2.md).
#### The `search` Method Callback

If you are passing a callback to the `search` method, the callback will now receive an instance of `Algolia/AlgoliaSearch/SearchIndex` as its first argument.

#### Misc.

If you are using the Algolia API client directly, consider reviewing the [full changelog provided by Algolia](https://github.com/algolia/algoliasearch-client-php/blob/master/docs/UPGRADE-from-v1-to-v2.md).
30 changes: 20 additions & 10 deletions src/EngineManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Laravel\Scout;

use Error;
use Exception;
use Illuminate\Support\Manager;
use Laravel\Scout\Engines\NullEngine;
use Laravel\Scout\Engines\AlgoliaEngine;
Expand All @@ -29,15 +29,7 @@ public function engine($name = null)
*/
public function createAlgoliaDriver()
{
if (! class_exists(Algolia::class)) {
if (class_exists('AlgoliaSearch\Client')) {
throw new Error('Laravel Scout do not support Algolia API Client v1. Update your
`algolia/algoliasearch-client-php` dependency to `^2.2` in your `composer.json` file.');
}

throw new Error('Algolia API Client not found. Add the
`"algolia/algoliasearch-client-php": "^2.2"` dependency to your `composer.json` file.');
}
$this->ensureAlgoliaClientIsInstalled();

UserAgent::addCustomUserAgent('Laravel Scout', '7.0.0');

Expand All @@ -46,6 +38,24 @@ public function createAlgoliaDriver()
));
}

/**
* Ensure the Algolia API client is installed.
*
* @return void
*/
protected function ensureAlgoliaClientIsInstalled()
{
if (class_exists(Algolia::class)) {
return;
}

if (class_exists('AlgoliaSearch\Client')) {
throw new Exception('Please upgrade your Algolia client to version: ^2.2.');
}

throw new Exception('Please install the Agolia client: algolia/algoliasearch-client-php.');
}

/**
* Create a Null engine instance.
*
Expand Down

0 comments on commit 85c636b

Please sign in to comment.