/**
  * Adds term reference field for the article content type.
  */
 protected function setUpTermReferenceField()
 {
     entity_create('field_storage_config', array('field_name' => $this->termFieldName, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => 0)))))->save();
     $field = entity_create('field_config', array('field_name' => $this->termFieldName, 'bundle' => 'article', 'entity_type' => 'node', 'translatable' => FALSE));
     $field->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'taxonomy_autocomplete'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'taxonomy_term_reference_link'))->save();
 }
 /**
  * Adds term reference field for the article content type.
  *
  * @param bool $translatable
  *   (optional) If TRUE, create a translatable term reference field. Defaults
  *   to FALSE.
  */
 protected function setUpTermReferenceField()
 {
     $handler_settings = array('target_bundles' => array($this->vocabulary->id() => $this->vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'article', $this->termFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     $field_storage = FieldStorageConfig::loadByName('node', $this->termFieldName);
     $field_storage->setTranslatable(FALSE);
     $field_storage->save();
     entity_get_form_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'entity_reference_autocomplete_tags'))->save();
     entity_get_display('node', 'article', 'default')->setComponent($this->termFieldName, array('type' => 'entity_reference_label'))->save();
 }