Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Partners Class Reference

Public Member Functions

 __construct (Curl $curl, Cache $cache, UrlInterface $backendUrl)
 
 getApiUrl ()
 
 getPartners ()
 
 getCurlClient ()
 
 getCache ()
 
 getReferer ()
 

Protected Attributes

 $curlClient
 
 $urlPrefix = 'https://'
 
 $apiUrl = 'magento.com/magento-connect/platinumpartners/list'
 
 $cache
 

Detailed Description

@api

Since
100.0.2

Definition at line 16 of file Partners.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Curl  $curl,
Cache  $cache,
UrlInterface  $backendUrl 
)
Parameters
Curl$curl
Cache$cache
UrlInterface$backendUrl

Definition at line 43 of file Partners.php.

44  {
45  $this->curlClient = $curl;
46  $this->cache = $cache;
47  $this->backendUrl = $backendUrl;
48  }

Member Function Documentation

◆ getApiUrl()

getApiUrl ( )
Returns
string

Definition at line 53 of file Partners.php.

54  {
55  return $this->urlPrefix . $this->apiUrl;
56  }

◆ getCache()

getCache ( )
Returns
cache

Definition at line 96 of file Partners.php.

97  {
98  return $this->cache;
99  }

◆ getCurlClient()

getCurlClient ( )
Returns
Curl

Definition at line 88 of file Partners.php.

89  {
90  return $this->curlClient;
91  }

◆ getPartners()

getPartners ( )

Gets partners json

Returns
array

Definition at line 63 of file Partners.php.

64  {
65  $apiUrl = $this->getApiUrl();
66  try {
67  $this->getCurlClient()->post($apiUrl, []);
68  $this->getCurlClient()->setOptions(
69  [
70  CURLOPT_REFERER => $this->getReferer()
71  ]
72  );
73  $response = json_decode($this->getCurlClient()->getBody(), true);
74  if ($response['partners']) {
75  $this->getCache()->savePartnersToCache($response['partners']);
76  return $response['partners'];
77  } else {
78  return $this->getCache()->loadPartnersFromCache();
79  }
80  } catch (\Exception $e) {
81  return $this->getCache()->loadPartnersFromCache();
82  }
83  }
$response
Definition: 404.php:11

◆ getReferer()

getReferer ( )
Returns
string

Definition at line 104 of file Partners.php.

105  {
106  return \Magento\Framework\App\Request\Http::getUrlNoScript($this->backendUrl->getBaseUrl())
107  . 'admin/marketplace/index/index';
108  }

Field Documentation

◆ $apiUrl

$apiUrl = 'magento.com/magento-connect/platinumpartners/list'
protected

Definition at line 31 of file Partners.php.

◆ $cache

$cache
protected

Definition at line 36 of file Partners.php.

◆ $curlClient

$curlClient
protected

Definition at line 21 of file Partners.php.

◆ $urlPrefix

$urlPrefix = 'https://'
protected

Definition at line 26 of file Partners.php.


The documentation for this class was generated from the following file: