/
DriverCollection.php
46 lines (37 loc) · 1.09 KB
/
DriverCollection.php
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
<?php
namespace Concrete\Core\Summary\Data\Extractor\Driver;
use Concrete\Core\Summary\Category\CategoryMemberInterface;
use Concrete\Core\Summary\Data\Collection;
use Concrete\Core\Summary\Data\Field\DataField;
use Doctrine\Common\Collections\ArrayCollection;
class DriverCollection
{
/**
* @var ArrayCollection
*/
protected $drivers;
public function __construct()
{
$this->drivers = new ArrayCollection();
}
public function addDriver(DriverInterface $driver)
{
$this->drivers->add($driver);
}
public function getDrivers()
{
return $this->drivers->toArray();
}
public function extractData(CategoryMemberInterface $mixed) : Collection
{
$collection = new Collection();
foreach($this->getDrivers() as $driver) {
$fields = $driver->extractData($mixed);
foreach($fields->getFields() as $key => $data) {
$dataField = new DataField($key, $data);
$collection->addField($dataField);
}
}
return $collection;
}
}