forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.php
More file actions
49 lines (40 loc) · 1.32 KB
/
Options.php
File metadata and controls
49 lines (40 loc) · 1.32 KB
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
47
48
49
<?php
namespace ProcessMaker\ImportExport;
use Illuminate\Support\Arr;
class Options
{
const IMPORT_OPTIONS = [
'mode' => [
'enum' => [
'update' => 'Update the existing asset with the one being imported',
'discard' => 'Keep the existing asset and discard the one being imported',
'copy' => 'Create a new asset and link dependent assets (in this import) to it',
],
'default' => 'update',
],
'isTemplate' => false,
'saveAssetsMode' => ['saveModelOnly', 'saveAllAssets'],
];
public $options;
public function __construct(array $options)
{
$this->options = $options;
}
// Name can only equal "mode" for now
public function get($name, $uuid)
{
$assetOptions = Arr::get($this->options, $uuid, []);
$option = self::IMPORT_OPTIONS[$name];
$importOptions = null;
if ($name === 'mode') {
$importOptions = self::IMPORT_OPTIONS[$name]['default'];
} else {
if (count($assetOptions) === 0) {
$importOptions = self::IMPORT_OPTIONS[$name][1];
} else {
$importOptions = self::IMPORT_OPTIONS[$name];
}
}
return Arr::get($assetOptions, $name, $importOptions);
}
}