You are here

public function GroupContentEnablerBase::getContentTypeConfigId in Group 8

Returns a safe, unique configuration ID for a group content type.

By default we use GROUP_TYPE_ID-PLUGIN_ID-DERIVATIVE_ID, but feel free to use any other means of identifying group content types.

Please do not return any invalid characters in the ID as it will crash the website. Refer to ConfigBase::validateName() for valid characters.

Return value

string The safe ID to use as the configuration name.

Overrides GroupContentEnablerInterface::getContentTypeConfigId

See also

\Drupal\Core\Config\ConfigBase::validateName()

1 call to GroupContentEnablerBase::getContentTypeConfigId()
GroupMembership::postInstall in src/Plugin/GroupContentEnabler/GroupMembership.php
Runs tasks after the group content type for this plugin has been created.

File

src/Plugin/GroupContentEnablerBase.php, line 169

Class

GroupContentEnablerBase
Provides a base class for GroupContentEnabler plugins.

Namespace

Drupal\group\Plugin

Code

public function getContentTypeConfigId() {
  $preferred_id = $this
    ->getGroupTypeId() . '-' . str_replace(':', '-', $this
    ->getPluginId());

  // Return a hashed ID if the readable ID would exceed the maximum length.
  if (strlen($preferred_id) > EntityTypeInterface::BUNDLE_MAX_LENGTH) {
    $hashed_id = 'group_content_type_' . md5($preferred_id);
    $preferred_id = substr($hashed_id, 0, EntityTypeInterface::BUNDLE_MAX_LENGTH);
  }
  return $preferred_id;
}