-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix php client not checking
null
region
- Loading branch information
Showing
3 changed files
with
16 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,18 +51,21 @@ use {{invokerPackage}}\Support\Helpers; | |
*/ | ||
public static function create($appId = null, $apiKey = null, $region = null) | ||
{ | ||
$allowedRegions = self::getAllowedRegions(); | ||
$config = {{configClassname}}::create($appId, $apiKey, $region, $allowedRegions); | ||
$allowedRegions = [{{#allowedRegions}}'{{.}}'{{^-last}},{{/-last}}{{/allowedRegions}}]; | ||
|
||
if ( | ||
{{^fallbackToAliasHost}}$region == null ||{{/fallbackToAliasHost}} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
shortcuts
Author
Member
|
||
($region !== null && !in_array($region, $allowedRegions, true)) | ||
) { | ||
throw new AlgoliaException( | ||
'`region` {{^fallbackToAliasHost}}is required and {{/fallbackToAliasHost}}must be one of the following: ' . | ||
implode(', ', $allowedRegions) | ||
); | ||
} | ||
|
||
return static::createWithConfig($config); | ||
} | ||
$config = {{configClassname}}::create($appId, $apiKey, $region); | ||
|
||
/** | ||
* Returns the allowed regions for the config | ||
*/ | ||
public static function getAllowedRegions() | ||
{ | ||
return [{{#allowedRegions}}'{{.}}'{{^-last}},{{/-last}}{{/allowedRegions}}]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
shortcuts
Author
Member
|
||
return static::createWithConfig($config); | ||
} | ||
{{/hasRegionalHost}} | ||
|
||
|
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
prefer
===
instead of==
Is this condition only useful for the Personalization client (where
{{{hostWithFallback}}}
is empty) ?