-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAdapter.php
More file actions
52 lines (38 loc) · 1005 Bytes
/
Adapter.php
File metadata and controls
52 lines (38 loc) · 1005 Bytes
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
<?php
namespace UniMapper;
abstract class Adapter implements Adapter\IAdapter
{
/** @var array */
private $afterExecute = [];
/** @var array */
private $beforeExecute = [];
/** @var Adapter\Mapping */
private $mapping;
public function __construct(Adapter\Mapping $mapping = null)
{
$this->mapping = $mapping;
}
final public function getMapping()
{
return $this->mapping;
}
public function beforeExecute(callable $callback)
{
$this->beforeExecute[] = $callback;
}
final public function execute(Adapter\IQuery $query)
{
foreach ($this->beforeExecute as $callback) {
$callback($query);
}
$result = $this->onExecute($query);
foreach ($this->afterExecute as $callback) {
$callback($query, $result);
}
return $result;
}
public function afterExecute(callable $callback)
{
$this->afterExecute[] = $callback;
}
}