/** * {@inheritdoc} */ public function collectViewVariables(FormView $view) { $hash = spl_object_hash($view); if (!isset($this->dataByView[$hash])) { $this->dataByView[$hash] = array(); } $this->dataByView[$hash] = array_replace($this->dataByView[$hash], $this->dataExtractor->extractViewVariables($view)); foreach ($view->children as $child) { $this->collectViewVariables($child); } }
public function testExtractViewVariables() { $view = new FormView(); $view->vars = array( 'b' => 'foo', 'a' => 'bar', 'c' => 'baz', 'id' => 'foo_bar', 'name' => 'bar', ); $this->assertSame(array( 'id' => 'foo_bar', 'name' => 'bar', 'view_vars' => array( 'a' => 'bar', 'b' => 'foo', 'c' => 'baz', 'id' => 'foo_bar', 'name' => 'bar', ), ), $this->dataExtractor->extractViewVariables($view)); }