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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @see https://github.com/laminas/laminas-hydrator for the canonical source repository
* @copyright https://github.com/laminas/laminas-hydrator/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-hydrator/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);
namespace Laminas\Hydrator\Aggregate;
use Laminas\EventManager\Event;
use function array_merge;
/**
* Event triggered when the {@see AggregateHydrator} extracts
* data from an object
*/
class ExtractEvent extends Event
{
public const EVENT_EXTRACT = 'extract';
/**
* {@inheritDoc}
*/
protected $name = self::EVENT_EXTRACT;
/**
* @var object
*/
protected $extractionObject;
/**
* @var mixed[] Data being extracted from the $extractionObject
*/
protected $extractedData = [];
public function __construct(object $target, object $extractionObject)
{
parent::__construct();
$this->target = $target;
$this->extractionObject = $extractionObject;
}
/**
* Retrieves the object from which data is extracted
*/
public function getExtractionObject() : object
{
return $this->extractionObject;
}
public function setExtractionObject(object $extractionObject) : void
{
$this->extractionObject = $extractionObject;
}
/**
* Retrieves the data that has been extracted
*
* @return mixed[]
*/
public function getExtractedData() : array
{
return $this->extractedData;
}
/**
* @param mixed[] $extractedData
*/
public function setExtractedData(array $extractedData) : void
{
$this->extractedData = $extractedData;
}
/**
* Merge provided data with the extracted data
*
* @param mixed[] $additionalData
*/
public function mergeExtractedData(array $additionalData) : void
{
$this->extractedData = array_merge($this->extractedData, $additionalData);
}
}