1 | <?php |
||
20 | abstract class AbstractProvider implements ProviderInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $baseOptions; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $objectClass; |
||
31 | |||
32 | /** |
||
33 | * @var ObjectPersisterInterface |
||
34 | */ |
||
35 | protected $objectPersister; |
||
36 | |||
37 | /** |
||
38 | * @var OptionsResolver |
||
39 | */ |
||
40 | protected $resolver; |
||
41 | |||
42 | /** |
||
43 | * @var IndexableInterface |
||
44 | */ |
||
45 | private $indexable; |
||
46 | |||
47 | /** |
||
48 | * Constructor. |
||
49 | * |
||
50 | * @param ObjectPersisterInterface $objectPersister |
||
51 | * @param IndexableInterface $indexable |
||
52 | * @param string $objectClass |
||
53 | * @param array $baseOptions |
||
54 | */ |
||
55 | 9 | public function __construct( |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 9 | public function populate(\Closure $loggerClosure = null, array $options = []) |
|
86 | |||
87 | /** |
||
88 | * Disables logging and returns the logger that was previously set. |
||
89 | * |
||
90 | * @return mixed |
||
91 | */ |
||
92 | abstract protected function disableLogging(); |
||
93 | |||
94 | /** |
||
95 | * Perform actual population. |
||
96 | * |
||
97 | * @param array $options |
||
98 | * @param \Closure $loggerClosure |
||
99 | */ |
||
100 | abstract protected function doPopulate($options, \Closure $loggerClosure = null); |
||
101 | |||
102 | /** |
||
103 | * Reenables the logger with the previously returned logger from disableLogging();. |
||
104 | * |
||
105 | * @param mixed $logger |
||
106 | * |
||
107 | * @return mixed |
||
108 | */ |
||
109 | abstract protected function enableLogging($logger); |
||
110 | |||
111 | /** |
||
112 | * Configures the option resolver. |
||
113 | */ |
||
114 | 9 | protected function configureOptions() |
|
128 | |||
129 | /** |
||
130 | * Filters objects away if they are not indexable. |
||
131 | * |
||
132 | * @param array $options |
||
133 | * @param array $objects |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | 9 | protected function filterObjects(array $options, array $objects) |
|
157 | |||
158 | /** |
||
159 | * Merges the base options provided by the class with options passed to the populate |
||
160 | * method and runs them through the resolver. |
||
161 | * |
||
162 | * @param array $options |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | 9 | protected function resolveOptions(array $options) |
|
170 | } |
||
171 |