Автор: Bernhard Schussek (bschussek@gmail.com)
Наследование: implements Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface
Пример #1
0
 /**
  * {@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);
     }
 }
Пример #2
0
    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));
    }