1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Basis; |
4
|
|
|
|
5
|
|
|
use Tarantool\Mapper\Entity; |
6
|
|
|
use Tarantool\Mapper\Mapper; |
7
|
|
|
|
8
|
|
|
trait Toolkit |
9
|
|
|
{ |
10
|
|
|
protected $app; |
11
|
|
|
|
12
|
28 |
|
public function __construct(Application $app) |
13
|
|
|
{ |
14
|
28 |
|
$this->app = $app; |
15
|
28 |
|
} |
16
|
|
|
|
17
|
1 |
|
public function create(string $space, array $data) : Entity |
18
|
|
|
{ |
19
|
1 |
|
return $this->get(Mapper::class)->create($space, $data); |
20
|
|
|
} |
21
|
|
|
|
22
|
28 |
|
public function dispatch(string $job, array $params = [], string $service = null) |
23
|
|
|
{ |
24
|
28 |
|
return $this->app->dispatch($job, $params, $service); |
25
|
|
|
} |
26
|
|
|
|
27
|
1 |
|
public function find(string $space, $params = []) : array |
28
|
|
|
{ |
29
|
1 |
|
return $this->get(Mapper::class)->find($space, $params); |
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
public function findOne(string $space, $params = []) : ?Entity |
33
|
|
|
{ |
34
|
1 |
|
return $this->get(Mapper::class)->findOne($space, $params); |
35
|
|
|
} |
36
|
|
|
|
37
|
1 |
|
public function findOrCreate(string $space, $params = []) : Entity |
38
|
|
|
{ |
39
|
1 |
|
return $this->get(Mapper::class)->findOrCreate($space, $params); |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
public function findOrFail(string $space, $params = []) : Entity |
43
|
|
|
{ |
44
|
1 |
|
return $this->get(Mapper::class)->findOrFail($space, $params); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function fire(string $event, array $context) |
48
|
|
|
{ |
49
|
|
|
return $this->get(Event::class)->fire($event, $context); |
50
|
|
|
} |
51
|
|
|
|
52
|
9 |
|
public function get(string $class) |
53
|
|
|
{ |
54
|
9 |
|
return $this->app->get($class); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getMapper() |
58
|
|
|
{ |
59
|
|
|
return $this->get(Mapper::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
public function remove(string $space, array $params = []) |
63
|
|
|
{ |
64
|
1 |
|
return $this->get(Mapper::class)->remove($space, $params); |
65
|
|
|
} |
66
|
|
|
|
67
|
2 |
|
public function select($fields, string $table, array $params) |
68
|
|
|
{ |
69
|
2 |
|
return $this->get(Clickhouse::class)->select($fields, $table, $params); |
70
|
|
|
} |
71
|
|
|
|
72
|
2 |
|
public function insert(string $table, array $data, array $headers) |
73
|
|
|
{ |
74
|
2 |
|
return $this->get(Clickhouse::class)->insert($table, $data, $headers); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function __debugInfo() |
78
|
|
|
{ |
79
|
|
|
$info = get_object_vars($this); |
80
|
|
|
unset($info['app']); |
81
|
|
|
return $info; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|