CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.0.4

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Backend/ClientActions.php

58lines · modecode

1<?php
2
3namespace CloudFlare\Plugin\Backend;
4
5use \CF\Integration\DefaultIntegration;
6use \CF\API\APIInterface;
7use \CF\API\Request;
8
9class ClientActions
10{
11 protected $api;
12 protected $config;
13 protected $integrationAPI;
14 protected $dataStore;
15 protected $logger;
16 protected $request;
17
18 /**
19 * @param DefaultIntegration $magentoIntegration
20 * @param APIInterface $api
21 * @param Request $request
22 */
23 public function __construct(DefaultIntegration $magentoIntegration, APIInterface $api, Request $request) {
24 $this->api = $api;
25 $this->config = $magentoIntegration->getConfig();
26 $this->integrationAPI = $magentoIntegration->getIntegrationAPI();
27 $this->dataStore = $magentoIntegration->getDataStore();
28 $this->logger = $magentoIntegration->getLogger();
29 $this->request = $request;
30 }
31
32 /*
33 * GET /zones
34 *
35 * To ensure the plugin can only be used to manage the current Magento installation we
36 * hook on this call to only return a list of size one of the current domain.
37 */
38 public function getZonesReturnMagentoZone() {
39 $magentoDomainName = $this->integrationAPI->getMagentoDomainName();
40 $this->request->setParameters(array('name' => $magentoDomainName));
41
42 $response = $this->api->callAPI($this->request);
43
44 if($this->api->responseOk($response)) {
45 if(count($response["result"] === 0 )) {
46 array_push($response["result"], array(
47 'name' => $magentoDomainName,
48 'plan' => array('name' => ''),
49 'type' => '',
50 'status' => 'inactive',
51 )
52 );
53 }
54 }
55
56 return $response;
57 }
58}