Esempio n. 1
0
 /**
  * Load a BundleGenerator into the symfony Kernel.
  *
  */
 public function datasetFieldAction($id)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $entity = $em->getRepository('LowbiConfiguratorBundle:REDataset')->find($id);
     $datasource = $entity->getDatasource();
     if ($datasource == null) {
         $myDatasource = null;
     } else {
         $myDatasource = $datasource->getName();
     }
     $query = $entity->getSqlStatement();
     $customEm = $this->getDoctrine()->getEntityManager($myDatasource);
     $conn = $customEm->getConnection();
     $result = $conn->fetchAll($query);
     $columns = array();
     $reDatasetFieldEntity = $em->getRepository('LowbiConfiguratorBundle:REDatasetField')->findByReDataset($entity->getId());
     foreach ($reDatasetFieldEntity as $item) {
         $em->remove($item);
     }
     $em->flush();
     $entityConfigurator = new EntityConfigurator();
     $entityConfigurator->setTableName($entity->getTableName());
     $entityConfigurator->setState('init');
     $entityConfigurator->setReadOnly(true);
     $em->persist($entityConfigurator);
     $em->flush();
     $fields = array();
     $i = 0;
     foreach ($result as $row) {
         foreach ($row as $key => $column) {
             $columns[] = $key;
             $reDatasetField = new REDatasetField();
             $reDatasetField->setFieldName($key);
             $reDatasetField->setFieldType('string');
             $reDatasetField->setReDataset($entity);
             $em->persist($reDatasetField);
             $field = new Field();
             $field->setFieldName($key);
             $field->setFieldType('string');
             $field->setFragment('text');
             $field->setPos($i);
             $field->setEntityConfigurator($entityConfigurator);
             $em->persist($field);
             $i++;
         }
         $em->flush();
         break;
     }
     return $this->redirect($this->generateUrl('entitygen_edit', array('id' => $entityConfigurator->getId())));
 }
Esempio n. 2
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $builder->add('fieldName', 'text', array('label' => 'field.fieldname', 'required' => true))->add('fieldType', 'choice', array('label' => 'field.fieldtype', 'choices' => Field::getFieldTypes(), 'required' => true, 'error_bubbling' => true))->add('fragment', 'choice', array('label' => 'field.fragment', 'choices' => Field::getFragmentTypes(), 'multiple' => false, 'required' => true, 'empty_data' => null, 'error_bubbling' => true))->add('length', 'number', array('label' => 'field.length', 'required' => false, 'error_bubbling' => true))->add('search', 'checkbox', array('label' => 'field.search', 'required' => false, 'error_bubbling' => true))->add('required', 'checkbox', array('label' => 'field.required', 'required' => false, 'error_bubbling' => true))->add('bundleName', 'text', array('label' => 'field.bundlename', 'required' => false, 'error_bubbling' => true))->add('entityName', 'text', array('label' => 'field.enittyname', 'required' => false, 'error_bubbling' => true))->add('relationType', 'choice', array('label' => 'field.relationtype', 'choices' => Field::getRelationTypes(), 'multiple' => false, 'required' => false, 'empty_data' => null, 'error_bubbling' => true))->add('propertyName', 'text', array('label' => 'field.propertyname', 'required' => false, 'error_bubbling' => true))->add('collectionItem', 'textarea', array('label' => 'field.collectionitem', 'required' => false, 'error_bubbling' => true))->add('id', 'hidden', array('label' => 'field.id', 'property_path' => FALSE));
 }
Esempio n. 3
0
 public function buildForm(FormBuilder $builder, array $options)
 {
     $subscriber = new EntityNameFieldSubscriber($builder->getFormFactory());
     $builder->addEventSubscriber($subscriber);
     $builder->add('fieldName', 'text', array('attr' => array('style' => 'width:120px;margin:0px;'), 'required' => true))->add('fieldType', 'choice', array('attr' => array('style' => 'width:120px;margin:0px;', 'class' => 'typeClass'), 'choices' => Field::getFieldTypes(), 'required' => true))->add('fragment', 'choice', array('attr' => array('style' => 'width:120px;margin:0px;', 'class' => 'fragmentClass'), 'choices' => Field::getFragmentTypes(), 'multiple' => false, 'required' => false, 'empty_data' => null))->add('length', 'number', array('attr' => array('style' => 'width:30px;margin:0px;'), 'required' => false))->add('search', 'checkbox', array('attr' => array('style' => 'margin:0px;'), 'required' => false))->add('required', 'checkbox', array('attr' => array('style' => 'margin:0px;'), 'required' => false))->add('bundleName', 'choice', array('attr' => array('style' => 'width:120px;margin:0px;', 'class' => 'bundleClass'), 'choices' => $this->bundles, 'required' => false))->add('entityName', 'choice', array('attr' => array('style' => 'width:120px;margin:0px;', 'class' => 'entityClass'), 'required' => false))->add('relationType', 'choice', array('attr' => array('style' => 'width:100px;margin:0px;', 'class' => 'relationClass'), 'choices' => Field::getRelationTypes(), 'multiple' => false, 'required' => false, 'empty_data' => null))->add('propertyName', 'choice', array('attr' => array('style' => 'width:120px;margin:0px;', 'class' => 'propertyClass'), 'required' => false))->add('collectionItem', 'textarea', array('attr' => array('style' => 'width:300px;margin:0px;display:none;'), 'required' => false))->add('id', 'hidden', array('attr' => array('style' => 'width:30px;margin:0px'), 'property_path' => false));
 }