diff --git a/README.md b/README.md index 2e14ed904..17dad2105 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ provide a quick way to get started with Organic groups. \Drupal\og\Og::groupManager()->addGroup('node', 'page'); // Add og audience field to "Article" node type, thus making is a group content. -\Drupal\og\Og::createField(\Drupal\og\OgAudienceFieldHelper::DEFAULT_FIELD, 'node', 'article'); +\Drupal\og\Og::createField(\Drupal\og\OgGroupAudienceHelper::DEFAULT_FIELD, 'node', 'article'); ``` ## FAQ diff --git a/og_ui/og_ui.module b/og_ui/og_ui.module index 9d4c6d7fd..711f96520 100644 --- a/og_ui/og_ui.module +++ b/og_ui/og_ui.module @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\field\Entity\FieldConfig; use Drupal\og\Og; +use Drupal\og\OgGroupAudienceHelper; use Drupal\og_ui\BundleFormAlter; /** @@ -65,16 +66,16 @@ function og_ui_entity_type_save(EntityInterface $entity) { $is_group_content = Og::isGroupContent($entity_type_id, $bundle); if ($entity->og_group_content_bundle != $is_group_content) { if ($entity->og_group_content_bundle) { - Og::createField(OG_AUDIENCE_FIELD, $entity_type_id, $bundle); + Og::createField(OgGroupAudienceHelper::DEFAULT_FIELD, $entity_type_id, $bundle); } - elseif ($field = FieldConfig::loadByName($entity_type_id, $bundle, OG_AUDIENCE_FIELD)) { + elseif ($field = FieldConfig::loadByName($entity_type_id, $bundle, OgGroupAudienceHelper::DEFAULT_FIELD)) { $field->delete(); return; } } // Change the field target type and bundle. - if ($field = FieldConfig::loadByName($entity_type_id, $bundle, OG_AUDIENCE_FIELD)) { + if ($field = FieldConfig::loadByName($entity_type_id, $bundle, OgGroupAudienceHelper::DEFAULT_FIELD)) { $handler_settings = $field->getSetting('handler_settings'); $save = FALSE; foreach (['target_type', 'target_bundles'] as $key) { diff --git a/og_ui/src/BundleFormAlter.php b/og_ui/src/BundleFormAlter.php index cd7ba13e0..c93fcaa2e 100644 --- a/og_ui/src/BundleFormAlter.php +++ b/og_ui/src/BundleFormAlter.php @@ -12,6 +12,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\field\Entity\FieldConfig; use Drupal\og\Og; +use Drupal\og\OgGroupAudienceHelper; /** * Helper for og_ui_form_alter(). @@ -112,7 +113,7 @@ protected function addGroupContent(array &$form, $form_state) { $target_type_default = FALSE; $handler_settings = []; - if ($field = FieldConfig::loadByName($this->entityTypeId, $this->bundle, OG_AUDIENCE_FIELD)) { + if ($field = FieldConfig::loadByName($this->entityTypeId, $this->bundle, OgGroupAudienceHelper::DEFAULT_FIELD)) { $handler_settings = $field->getSetting('handler_settings'); if (isset($handler_settings['target_type'])) { $target_type_default = $handler_settings['target_type'];