backdrop-contrib / og

The Organic Groups module provides users the ability to create, manage, and delete 'groups' on a site.
GNU General Public License v2.0
1 stars 8 forks source link

Missing 'Default' OG membership type #12

Closed VasasA closed 2 years ago

VasasA commented 3 years ago

When I install OG module in the D7, the 'Default' OG membership type is created automatically. It is missing from the BD version. See this page: admin/config/group/group-membership

(I cannot solve this problem in my unfinished ported OG module.)

kép

laryn commented 3 years ago

Must be some kind of hook that is not firing...

VasasA commented 2 years ago

I think it is the solution: Insert line entity_plus_defaults_rebuild(array('og_membership_type')); at the end of og_install(). Because entity_plus_defaults_rebuild() will save what og_default_og_membership_type() imports: $items['og_membership_type_default']

OR we should implement hook_modules_enabled() and _entity_plus_modules_get_default_types() functions in the Entity Plus module. (Entity module implements these functions in D7.) entity_plus.module:


/**
 * Implements hook_modules_enabled().
 */
function entity_plus_modules_enabled($modules) {
  foreach (_entity_plus_modules_get_default_types($modules) as $type) {
    _entity_plus_defaults_rebuild($type);
  }
}

/**
 * Gets all entity types for which defaults are provided by the $modules.
 */
function _entity_plus_modules_get_default_types($modules) {
  $types = array();
  foreach (entity_plus_crud_get_info() as $entity_type => $info) {
    if (!empty($info['exportable'])) {
      $hook = isset($info['export']['default hook']) ? $info['export']['default hook'] : 'default_' . $entity_type;
      foreach ($modules as $module) {
        if (module_hook($module, $hook) || module_hook($module, $hook . '_alter')) {
          $types[] = $entity_type;
        }
      }
    }
  }
  return $types;
}

(Entity module implements further functions in D7, but the Entity Plus doesn't in BD: hook_modules_disabled(), hook_modules_installed(), hook_modules_uninstalled(), hook_flush_caches() Need we these?)

laryn commented 2 years ago

I'll leave this open for now pending the outcome of the issue in the Entity Plus queue which may solve it without needing further changes here.

laryn commented 2 years ago

Closing as I believe this was fixed by @VasasA here: https://github.com/backdrop-contrib/entity_plus/issues/119

olafgrabienski commented 2 years ago

Confirming: when I installed OG and the latest Entity Plus including the fix, og_membership_type_default has been created.

VasasA commented 2 years ago

Yes, fixed by Entity Plus. "1.x-1.0.15" version will be released soon. Thank You!