Example #1
0
 /**
  * Provide default route defaults and extract defaults from $dynamicDefaults.
  *
  * @param array $dynamicDefaults
  *
  * @return array Value for sonata_type_immutable_array
  */
 protected function configureFieldsForDefaults($dynamicDefaults)
 {
     $defaults = array('_controller' => array('_controller', Sf2CompatUtil::getFormTypeName('text'), array('required' => false)), '_template' => array('_template', Sf2CompatUtil::getFormTypeName('text'), array('required' => false)), 'type' => array('type', Sf2CompatUtil::getFormTypeName('cmf_routing_route_type'), array('empty_value' => '', 'required' => false)));
     foreach ($dynamicDefaults as $name => $value) {
         if (!isset($defaults[$name])) {
             $defaults[$name] = array($name, Sf2CompatUtil::getFormTypeName('text'), array('required' => false));
         }
     }
     //parse variable pattern and add defaults for tokens - taken from routecompiler
     /** @var $route Route */
     $route = $this->subject;
     if ($route && $route->getVariablePattern()) {
         preg_match_all('#\\{\\w+\\}#', $route->getVariablePattern(), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             $name = substr($match[0][0], 1, -1);
             if (!isset($defaults[$name])) {
                 $defaults[$name] = array($name, Sf2CompatUtil::getFormTypeName('text'), array('required' => true));
             }
         }
     }
     if ($route && $route->getOption('add_format_pattern')) {
         $defaults['_format'] = array('_format', Sf2CompatUtil::getFormTypeName('text'), array('required' => true));
     }
     if ($route && $route->getOption('add_locale_pattern')) {
         $defaults['_locale'] = array('_locale', Sf2CompatUtil::getFormTypeName('text'), array('required' => false));
     }
     return $defaults;
 }
 public function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('form.group_routes', array('translation_domain' => 'CmfRoutingBundle'))->add('routes', Sf2CompatUtil::getFormTypeName('sonata_type_collection'), array(), array('edit' => 'inline', 'inline' => 'table'))->end();
 }
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with('form.group_general')->add('parent', Sf2CompatUtil::getFormTypeName('doctrine_phpcr_odm_tree'), array('choice_list' => array(), 'select_root_node' => true, 'root_node' => $this->routeRoot))->add('name', Sf2CompatUtil::getFormTypeName('text'))->add('routeName', Sf2CompatUtil::getFormTypeName('text'), array('required' => false))->add('uri', Sf2CompatUtil::getFormTypeName('text'), array('required' => false))->add('routeTarget', Sf2CompatUtil::getFormTypeName('doctrine_phpcr_odm_tree'), array('choice_list' => array(), 'required' => false, 'root_node' => $this->routeRoot))->end();
 }
Example #4
0
 /**
  * Provide default options and extract options from $dynamicOptions.
  *
  * @param array $dynamicOptions
  *
  * @return array Value for sonata_type_immutable_array
  */
 protected function configureFieldsForOptions(array $dynamicOptions)
 {
     $checkboxType = Sf2CompatUtil::getFormTypeName('checkbox');
     $options = array('add_locale_pattern' => array('add_locale_pattern', $checkboxType, array('required' => false, 'label' => 'form.label_add_locale_pattern', 'translation_domain' => 'CmfRoutingBundle')), 'add_format_pattern' => array('add_format_pattern', $checkboxType, array('required' => false, 'label' => 'form.label_add_format_pattern', 'translation_domain' => 'CmfRoutingBundle')), 'add_trailing_slash' => array('add_trailing_slash', $checkboxType, array('required' => false, 'label' => 'form.label_add_trailing_slash', 'translation_domain' => 'CmfRoutingBundle')));
     foreach ($dynamicOptions as $name => $value) {
         if (!isset($options[$name])) {
             $options[$name] = array($name, 'text', array('required' => false));
         }
     }
     return $options;
 }