-
Notifications
You must be signed in to change notification settings - Fork 0
/
LayoutDataResource.php
71 lines (56 loc) · 1.87 KB
/
LayoutDataResource.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
<?php
namespace DynamicPDF\Api;
include_once __DIR__ . '/Resource.php';
include_once __DIR__ . '/ResourceType.php';
/**
*
* Represents the Layout data resource used to create the PDF reports.
*
*/
class LayoutDataResource extends Resource
{
/**
*
* Initializes a new instance of the LayoutDataResource class using the layout data object and a resource
* name.
*
* @param array|string $layout Data to create PDF report as an array of JSON content or as a string of JSON file path.
* @param string $layoutDataResourceName The name for layout data resource.
*/
public function __construct($layout = null, string $layoutDataResourceName = null)
{
if (gettype($layout) == "array") {
$this->Data = implode($layout);
} else if (gettype($layout) == "string") {
if (pathinfo($layout, PATHINFO_EXTENSION) == "json") {
$this->Data = Resource::_GetFileData($layout);
} else {
$this->Data = mb_convert_encoding($layout, 'UTF-8');
}
}
if ($layoutDataResourceName == null) {
$this->LayoutDataResourceName = md5(uniqid(rand(), true)) . ".json";
} else {
$this->LayoutDataResourceName = $layoutDataResourceName;
}
$this->_MimeType = "application/json";
$this->_Type = ResourceType::LayoutData;
$this->ResourceName = $this->LayoutDataResourceName;
}
public $_Type = ResourceType::LayoutData;
public function _FileExtension()
{
return ".json";
}
public $_MimeType = "application/json";
/**
*
* Gets or sets name of the layout data resource.
*
*/
public $LayoutDataResourceName;
public function GetJsonSerializeString()
{
return null;
}
}