protected function createInstance()
 {
     $entities = entity_get_info();
     $entityList = array_keys($entities);
     $entity = $this->dialog->select($this->output, 'What entity? ', $entityList);
     $entity = $entityList[$entity];
     $bundles = field_info_bundles($entity);
     $bundleList = array_keys($bundles);
     $bundle = $this->dialog->select($this->output, 'What bundle? ', $bundleList);
     $bundle = $bundleList[$bundle];
     $field_types = FieldBuilder::getFields();
     $fieldList = array();
     foreach ($field_types as $field => $definition) {
         $fieldList[$field] = sprintf("%s (%s)", $definition['label'], $field);
     }
     $fieldValues = array_keys($field_types);
     $field = $this->dialog->select($this->output, 'Field To Attach', array_values($fieldList));
     $field = $fieldValues[$field];
     $widget_types = WidgetBuilder::getTypesForFieldType($field_types[$field]['type']);
     $widgetList = array_keys($widget_types);
     $widget = $this->dialog->select($this->output, 'Widget to Use', array_values($widget_types));
     $widget = $widgetList[$widget];
     $label = $this->dialog->ask($this->output, 'What label for this instance? ');
     $widgetDefinition = new WidgetBuilder($widget, $label);
     $builder = new InstanceBuilder($field, $label, $widgetDefinition);
     $builder->build($entity, $bundle);
     $this->output->writeln("Created instance of field {$field} with label <info>{$label}</info> on {$entity}:{$bundle}");
     $this->mainQuestion();
 }
 public function addInstance(InstanceBuilder $instances)
 {
     $this->instances[$instances->getFieldName()] = $instances;
 }