/** * @param array $path * @return Data[] */ public function data(array $path) { $source = $this->sourceForPath($path); if ($source === null) { throw new RouteNotFoundException($path); } $combined = DataCombiner::combine($source->getDataProviderInstance($this->classInitializer)->handle($path)); return (new ReferenceResolver($this))->process($combined); }
public function testCombineMultiple() { /* Given */ $data = [Data::build(['foo', 1], ['foo' => 'bar']), Data::build(['foo', 1], ['name' => 'bar2']), Data::build(['foo', 2], ['foo2' => 'bar']), Data::build(['foo', 2], ['name2' => 'bar2'])]; /* When */ $result = DataCombiner::combine($data); /* Then */ assertThat(count($result), is(2)); assertThat($result[0]->getValue(), is(['foo' => 'bar', 'name' => 'bar2'])); assertThat($result[1]->getValue(), is(['foo2' => 'bar', 'name2' => 'bar2'])); }