add factory class
This commit is contained in:
parent
b4841a871d
commit
b33f3e05a0
1 changed files with 24 additions and 0 deletions
24
intaro.retailcrm/lib/component/factory/factory.php
Normal file
24
intaro.retailcrm/lib/component/factory/factory.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Intaro\RetailCrm\Component\Factory;
|
||||
|
||||
use Bitrix\Main\Config\Option;
|
||||
use Intaro\RetailCrm\Component\ApiClient\ClientAdapter;
|
||||
|
||||
class ClientFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @return \Intaro\RetailCrm\Component\ApiClient\ClientAdapter|null
|
||||
*/
|
||||
public static function creacteClientAdapter(): ?ClientAdapter
|
||||
{
|
||||
$apiHost = Option::get('intaro.retailcrm', 'api_host');
|
||||
$apiKey = Option::get('intaro.retailcrm', 'api_key');
|
||||
if (empty($apiHost) || empty($apiKey)) {
|
||||
return null;
|
||||
} else {
|
||||
return new ClientAdapter;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue