Symfony\Component\Form\Extension\DataCollector\FormDataExtractor::extractConfiguration PHP Method

extractConfiguration() public method

public extractConfiguration ( Symfony\Component\Form\FormInterface $form )
$form Symfony\Component\Form\FormInterface
    public function extractConfiguration(FormInterface $form)
    {
        $data = array(
            'id' => $this->buildId($form),
            'name' => $form->getName(),
            'type_class' => get_class($form->getConfig()->getType()->getInnerType()),
            'synchronized' => $form->isSynchronized(),
            'passed_options' => array(),
            'resolved_options' => array(),
        );

        foreach ($form->getConfig()->getAttribute('data_collector/passed_options', array()) as $option => $value) {
            $data['passed_options'][$option] = $value;
        }

        foreach ($form->getConfig()->getOptions() as $option => $value) {
            $data['resolved_options'][$option] = $value;
        }

        ksort($data['passed_options']);
        ksort($data['resolved_options']);

        return $data;
    }

Usage Example

Esempio n. 1
0
 public function testExtractConfigurationBuildsIdRecursively()
 {
     $type = $this->getMock('Symfony\\Component\\Form\\ResolvedFormTypeInterface');
     $type->expects($this->any())->method('getInnerType')->will($this->returnValue(new \stdClass()));
     $grandParent = $this->createBuilder('grandParent')->setCompound(true)->setDataMapper($this->getMock('Symfony\\Component\\Form\\DataMapperInterface'))->getForm();
     $parent = $this->createBuilder('parent')->setCompound(true)->setDataMapper($this->getMock('Symfony\\Component\\Form\\DataMapperInterface'))->getForm();
     $form = $this->createBuilder('name')->setType($type)->getForm();
     $grandParent->add($parent);
     $parent->add($form);
     $this->assertSame(array('id' => 'grandParent_parent_name', 'name' => 'name', 'type_class' => 'stdClass', 'synchronized' => true, 'passed_options' => array(), 'resolved_options' => array()), $this->dataExtractor->extractConfiguration($form));
 }
All Usage Examples Of Symfony\Component\Form\Extension\DataCollector\FormDataExtractor::extractConfiguration