1: <?php
2:
3: /**
4: * Deep
5: *
6: * @package rsanchez\Deep
7: * @author Rob Sanchez <info@robsanchez.com>
8: */
9:
10: namespace rsanchez\Deep\Hydrator;
11:
12: use Illuminate\Database\Eloquent\Model;
13: use rsanchez\Deep\Collection\EntryCollection;
14: use rsanchez\Deep\Model\AbstractEntity;
15: use rsanchez\Deep\Model\AbstractProperty;
16:
17: /**
18: * Abstract Hydrator class
19: *
20: * Hydrators bind custom fields properties to Entry objects
21: */
22: abstract class AbstractHydrator implements HydratorInterface
23: {
24: /**
25: * The Entry Collection being hydrated
26: * @var \rsanchez\Deep\Collection\EntryCollection
27: */
28: protected $collection;
29:
30: /**
31: * The name of the fieldtype
32: * @var string
33: */
34: protected $fieldtype;
35:
36: /**
37: * Constructor
38: *
39: * Set the EntryCollection and load any global elements the hydrator might need
40: * @param \rsanchez\Deep\Collection\EntryCollection $collection
41: * @param string $fieldtype
42: */
43: public function __construct(EntryCollection $collection, $fieldtype)
44: {
45: $this->collection = $collection;
46: $this->fieldtype = $fieldtype;
47: }
48:
49: /**
50: * {@inheritdoc}
51: */
52: public function preload(array $entryIds)
53: {
54: // load from external DBs here
55: }
56:
57: /**
58: * {@inheritdoc}
59: */
60: abstract public function hydrate(AbstractEntity $entity, AbstractProperty $property);
61: }
62: