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