|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** EventArgs.php */ |
|
11
|
|
|
namespace Core\Repository\DoctrineMongoODM\Event; |
|
12
|
|
|
|
|
13
|
|
|
class EventArgs extends \Doctrine\Common\EventArgs |
|
14
|
|
|
{ |
|
15
|
|
|
private $values; |
|
16
|
|
|
|
|
17
|
7 |
|
public function __construct(array $values = array()) |
|
18
|
|
|
{ |
|
19
|
7 |
|
$this->values = $values; |
|
20
|
7 |
|
} |
|
21
|
|
|
|
|
22
|
3 |
|
public function get($key) |
|
23
|
|
|
{ |
|
24
|
3 |
|
if (!isset($this->values[$key])) { |
|
25
|
|
|
throw new \OutOfBoundsException('Invalid key "' . $key . '"'); |
|
26
|
|
|
} |
|
27
|
3 |
|
return $this->values[$key]; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function set($key, $value) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->values[$key] = $value; |
|
33
|
|
|
return $this; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function __get($name) |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->get($name); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function __set($name, $value) |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->set($name, $value); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function __call($method, $params) |
|
47
|
|
|
{ |
|
48
|
|
|
$type = substr($method, 0, 3); |
|
49
|
|
|
|
|
50
|
|
|
if ('get' == $type || 'set' == $type) { |
|
51
|
|
|
$filter = function ($match) { |
|
52
|
|
|
return '_' . strtolower($match[0]); |
|
53
|
|
|
}; |
|
54
|
|
|
$key = lcfirst(substr($method, 3)); |
|
55
|
|
|
$key = preg_replace_callback('~([A-Z])~', $filter, $key); |
|
56
|
|
|
|
|
57
|
|
|
return 'get' == $type ? $this->get($key) : $this->set($key, (isset($params[0]) ? $params[0] : null)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
throw new \BadMethodCallException('Unknown method: ' . $method); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|