forked from fastly/fastly-magento2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDictionary.php
46 lines (38 loc) · 947 Bytes
/
Dictionary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Fastly\Cdn\Model\Upload;
use Fastly\Cdn\Model\Api;
use Fastly\Cdn\Model\Config;
class Dictionary
{
/**
* @var Api
*/
private $api;
/**
* @param Api $api
*/
public function __construct(
Api $api
) {
$this->api = $api;
}
/**
* @param $cloneNumber
* @param $currActiveVersion
* @return bool|mixed
*/
public function setupDictionary($cloneNumber, $currActiveVersion)
{
try {
$dictionaryName = Config::CONFIG_DICTIONARY_NAME;
$dictionary = $this->api->getSingleDictionary($currActiveVersion, $dictionaryName);
if (!$dictionary) {
$params = ['name' => $dictionaryName];
$dictionary = $this->api->createDictionary($cloneNumber, $params);
}
return $dictionary;
} catch (\Exception $e) {
return false;
}
}
}