-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/103.5.0' into 'master'
release/103.5.0 into master See merge request agence-dnd/marketplace/magento-2/external/magento2-connector-community!97
- Loading branch information
Showing
9 changed files
with
590 additions
and
336 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 |
---|---|---|
|
@@ -7,14 +7,18 @@ | |
use Akeneo\Pim\ApiClient\AkeneoPimClientInterface; | ||
use Akeneo\Pim\ApiClient\AkeneoPimClientBuilder; | ||
use Akeneo\Connector\Helper\Config as ConfigHelper; | ||
use Exception; | ||
use Http\Factory\Guzzle\StreamFactory; | ||
use Http\Factory\Guzzle\RequestFactory; | ||
use Symfony\Component\HttpClient\Psr18Client; | ||
|
||
/** | ||
* Class Authenticator | ||
* | ||
* @package Akeneo\Connector\Helper | ||
* @author Agence Dn'D <[email protected]> | ||
* @copyright 2004-present Agence Dn'D | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
* @link https://www.dnd.fr/ | ||
*/ | ||
class Authenticator | ||
|
@@ -24,12 +28,17 @@ class Authenticator | |
* | ||
* @var ConfigHelper $configHelper | ||
*/ | ||
protected $configHelper; | ||
protected Config $configHelper; | ||
|
||
/** | ||
* @var AkeneoPimClientInterface|null $akeneoClient | ||
*/ | ||
private ?AkeneoPimClientInterface $akeneoClient = null; | ||
|
||
/** | ||
* Authenticator constructor | ||
* | ||
* @param ConfigHelper $configHelper | ||
* @param Config $configHelper | ||
*/ | ||
public function __construct( | ||
ConfigHelper $configHelper | ||
|
@@ -40,32 +49,32 @@ public function __construct( | |
/** | ||
* Retrieve an authenticated akeneo php client | ||
* | ||
* @return AkeneoPimClientInterface|false | ||
* @return AkeneoPimClientInterface|null | ||
* @throws Exception | ||
*/ | ||
public function getAkeneoApiClient() | ||
public function getAkeneoApiClient(): ?AkeneoPimClientInterface | ||
{ | ||
/** @var string $baseUri */ | ||
if ($this->akeneoClient !== null) { | ||
return $this->akeneoClient; | ||
} | ||
|
||
$baseUri = $this->configHelper->getAkeneoApiBaseUrl(); | ||
/** @var string $clientId */ | ||
$clientId = $this->configHelper->getAkeneoApiClientId(); | ||
/** @var string $secret */ | ||
$secret = $this->configHelper->getAkeneoApiClientSecret(); | ||
/** @var string $username */ | ||
$username = $this->configHelper->getAkeneoApiUsername(); | ||
/** @var string $password */ | ||
$password = $this->configHelper->getAkeneoApiPassword(); | ||
|
||
if (!$baseUri || !$clientId || !$secret || !$username || !$password) { | ||
return false; | ||
return null; | ||
} | ||
|
||
/** @var AkeneoPimClientBuilder $akeneoClientBuilder */ | ||
$akeneoClientBuilder = new AkeneoPimClientBuilder($baseUri); | ||
|
||
$akeneoClientBuilder->setHttpClient(new Psr18Client()); | ||
$akeneoClientBuilder->setStreamFactory(new StreamFactory()); | ||
$akeneoClientBuilder->setRequestFactory(new RequestFactory()); | ||
|
||
return $akeneoClientBuilder->buildAuthenticatedByPassword($clientId, $secret, $username, $password); | ||
$this->akeneoClient = $akeneoClientBuilder->buildAuthenticatedByPassword($clientId, $secret, $username, $password); | ||
|
||
return $this->akeneoClient; | ||
} | ||
} |
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
Oops, something went wrong.