1<?php
2/**
3 * Zend Framework (http://framework.zend.com/)
4 *
5 * @link      http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license   http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10namespace Zend\Db\TableGateway\Feature\EventFeature;
11
12use Zend\Db\TableGateway\AbstractTableGateway;
13use Zend\EventManager\EventInterface;
14
15class TableGatewayEvent implements EventInterface
16{
17    /**
18     * @var AbstractTableGateway
19     */
20    protected $target = null;
21
22    /**
23     * @var null
24     */
25    protected $name = null;
26
27    /**
28     * @var array|\ArrayAccess
29     */
30    protected $params = [];
31
32    /**
33     * Get event name
34     *
35     * @return string
36     */
37    public function getName()
38    {
39        return $this->name;
40    }
41
42    /**
43     * Get target/context from which event was triggered
44     *
45     * @return null|string|object
46     */
47    public function getTarget()
48    {
49        return $this->target;
50    }
51
52    /**
53     * Get parameters passed to the event
54     *
55     * @return array|\ArrayAccess
56     */
57    public function getParams()
58    {
59        return $this->params;
60    }
61
62    /**
63     * Get a single parameter by name
64     *
65     * @param  string $name
66     * @param  mixed $default Default value to return if parameter does not exist
67     * @return mixed
68     */
69    public function getParam($name, $default = null)
70    {
71        return (isset($this->params[$name]) ? $this->params[$name] : $default);
72    }
73
74    /**
75     * Set the event name
76     *
77     * @param  string $name
78     * @return void
79     */
80    public function setName($name)
81    {
82        $this->name = $name;
83    }
84
85    /**
86     * Set the event target/context
87     *
88     * @param  null|string|object $target
89     * @return void
90     */
91    public function setTarget($target)
92    {
93        $this->target = $target;
94    }
95
96    /**
97     * Set event parameters
98     *
99     * @param  string $params
100     * @return void
101     */
102    public function setParams($params)
103    {
104        $this->params = $params;
105    }
106
107    /**
108     * Set a single parameter by key
109     *
110     * @param  string $name
111     * @param  mixed $value
112     * @return void
113     */
114    public function setParam($name, $value)
115    {
116        $this->params[$name] = $value;
117    }
118
119    /**
120     * Indicate whether or not the parent EventManagerInterface should stop propagating events
121     *
122     * @param  bool $flag
123     * @return void
124     */
125    public function stopPropagation($flag = true)
126    {
127        return;
128    }
129
130    /**
131     * Has this event indicated event propagation should stop?
132     *
133     * @return bool
134     */
135    public function propagationIsStopped()
136    {
137        return false;
138    }
139}
140