-
Notifications
You must be signed in to change notification settings - Fork 0
/
DlexInput.php
83 lines (70 loc) · 3.02 KB
/
DlexInput.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace DynamicPDF\Api;
include_once __DIR__ . '/Input.php';
include_once __DIR__ . '/DlexResource.php';
include_once __DIR__ . '/LayoutDataResource.php';
include_once __DIR__ . '/InputType.php';
/**
*
* Represents a Dlex input.
*
*/
class DlexInput extends Input
{
/**
*
* Initializes a new instance of the DlexInput class by posting the DLEX file and the JSON data file from
* the client to the API to create the PDF report.
*
* @param string|DlexResource $dlex The DLEX file path present in the resource manager or the DlexResource file created as per the desired PDF report layout design.
* @param string|LayoutDataResource $layout The JSON data file path present in the resource manager used to create the PDF report or the LayoutDataResource file used to create the PDF report.
*/
public function __construct($dlex, $layout)
{
if ((gettype($dlex) == "object") && (gettype($layout) == "object")) {
$this->ResourceName = $dlex->ResourceName;
$this->LayoutDataResourceName = $layout->LayoutDataResourceName;
array_push($this->_Resources, $layout);
array_push($this->_Resources, $dlex);
} else if ((gettype($dlex) == "object") && (gettype($layout) == "string")) {
$this->ResourceName = $dlex->ResourceName;
$layoutDataResource = new LayoutDataResource($layout);
$this->LayoutDataResourceName = $layoutDataResource->LayoutDataResourceName;
array_push($this->_Resources, $layoutDataResource);
array_push($this->_Resources, $dlex);
} else if ((gettype($dlex) == "string") && (gettype($layout) == "object")) {
$this->ResourceName = $dlex;
$this->LayoutDataResourceName = $layout->LayoutDataResourceName;
array_push($this->_Resources, $layout);
} else if ((gettype($dlex) == "string") && (gettype($layout) == "string")) {
$this->ResourceName = $dlex;
$layoutDataResource = new LayoutDataResource($layout);
$this->LayoutDataResourceName = $layoutDataResource->LayoutDataResourceName;
array_push($this->_Resources, $layoutDataResource);
}
}
public $_Type = InputType::Dlex;
/**
*
* Gets or sets the name for layout data resource.
*
*/
public $LayoutDataResourceName;
public function GetJsonSerializeString()
{
$jsonArray = array();
$jsonArray['type'] = 'dlex';
$jsonArray['layoutDataResourceName'] = $this->LayoutDataResourceName;
//---------------------------------------------------
if ($this->_TemplateId != null) {
$jsonArray['templateId'] = $this->_TemplateId;
}
if ($this->ResourceName != null) {
$jsonArray['resourceName'] = $this->ResourceName;
}
if ($this->Id != null) {
$jsonArray['id'] = $this->Id;
}
return $jsonArray;
}
}