forked from basis-company/tarantool-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJob.php
49 lines (41 loc) · 1.07 KB
/
Job.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
<?php
namespace Job\Space;
use Job\Database\Job as DatabaseJob;
use Exception;
use Tarantool\Mapper\Space;
abstract class Job extends DatabaseJob
{
public int $index;
public string $space;
public string $truncateButtonText;
private Space $spaceInstance;
public function getSpace(): Space
{
if (isset($this->spaceInstance)) {
return $this->spaceInstance;
}
if (!$this->space) {
throw new Exception('space name is not defined');
}
return $this->spaceInstance = $this->getMapper()->getSpace($this->space);
}
public function getFormat()
{
$format = [];
foreach ($this->spaceInstance->getFields() as $field) {
$format[] = $this->spaceInstance->getFieldFormat($field);
}
return $format;
}
public function trimTail($arr): array
{
$trimArr = [];
foreach ($arr as $value) {
if ($value === null) {
break;
}
$trimArr[] = $value;
}
return $trimArr;
}
}