Skip to content

Entities

The module defines three entity types: one config entity (Membership Type) and two content entities (Membership and Membership Period). Source: src/Entity/.

Membership

Class: Drupal\crm_membership\Entity\Membership
Entity type ID: crm_membership
Base table: crm_membership
Revision table: crm_membership_revision

Content entity representing a membership record. It links one or more Contact entities (the members) to a target Contact (the “member of” entity, e.g. an organization). Each membership has a bundle (Membership Type) that selects the Membership Term plugin and its configuration.

Entity keys

Key Field
id id
revision vid
bundle type
uuid uuid
label id (label is built dynamically)

Base fields

Field Type Description
contacts entity_reference (crm_contact, unlimited) The contact(s) who are members.
target_contact entity_reference (crm_contact, 1) The contact this membership is “for” (member of).
status list_string active, future, or expired.
current_periods entity_reference (crm_membership_period, unlimited) Current membership period(s) for this membership.
created created Creation timestamp.
changed changed Last change timestamp.
Link Path
canonical /admin/content/crm/membership/{crm_membership}
add-page /admin/content/crm/membership/add
add-form /admin/content/crm/membership/add/{crm_membership_type}
edit-form /admin/content/crm/membership/{crm_membership}/edit
delete-form /admin/content/crm/membership/{crm_membership}/delete
renew-form /admin/content/crm/membership/{crm_membership}/renew
collection /admin/content/crm/membership

Handlers

  • Views data: MembershipViewsData — exposes a “Label” field and sets the base default field to label.
  • Access: MembershipAccessControlHandler.
  • Route provider: MembershipRouteHtmlRouteProvider.
  • Forms: default/add/edit MembershipForm, delete ContentEntityDeleteForm, renew MembershipRenewForm.

Notable methods on the entity: getType(), getContacts(), getTargetContact(), getStatus(), getCurrentPeriods(), getCurrentPeriodsForContact(), isActiveFor(Contact $contact) (delegates to the term plugin).


Membership Type

Class: Drupal\crm_membership\Entity\MembershipType
Entity type ID: crm_membership_type
Config prefix: crm_membership_type

Config entity that acts as the bundle for crm_membership. Defines the membership category (label, description), optional default target contact, and which Membership Term plugin to use plus its configuration.

Config export keys

  • id
  • label
  • description
  • default_target_contact
  • membership_term (plugin ID)
  • membership_term_config (sequence of plugin config)
Link Path
add-form /admin/structure/crm/membership_types/add
edit-form /admin/structure/crm/membership_types/{crm_membership_type}/edit
delete-form /admin/structure/crm/membership_types/{crm_membership_type}/delete
collection /admin/structure/crm/membership_types

Handlers

  • Access: MembershipTypeAccessControlHandler — grants view, update, delete, and create when the user has the corresponding granular permission or administer crm_membership.
  • List builder: MembershipTypeListBuilder.
  • Form: add/edit MembershipTypeForm, delete EntityDeleteForm.
  • Route provider: AdminHtmlRouteProvider.

The entity definition sets collection permission view crm membership types for the collection route.

Methods: getMembershipTermPluginId(), getMembershipTermPluginConfig().


Membership Period

Class: Drupal\crm_membership\Entity\MembershipPeriod
Entity type ID: crm_membership_period
Base table: crm_membership_period
Revision table: crm_membership_period_revision

Content entity representing a single time span of a membership. It has a date range and optional applicable contacts; if applicable contacts are not set, the period applies to all contacts on the parent membership (e.g. for household memberships, a period can restrict which contacts are covered).

Entity keys

Key Field
id id
revision vid
uuid uuid
label id (label built from dates and contacts)

Base fields

Field Type Description
membership entity_reference (crm_membership, 1) Parent membership.
date_range daterange Start and end datetime for the period.
applicable_contacts entity_reference (crm_contact, unlimited) Contacts this period applies to; empty means all contacts on the membership.
created created Creation timestamp.
changed changed Last change timestamp.
Link Path
canonical /admin/content/crm/membership/periods/{crm_membership_period}
add-form /admin/content/crm/membership/periods/add
edit-form /admin/content/crm/membership/periods/{crm_membership_period}/edit
delete-form /admin/content/crm/membership/periods/{crm_membership_period}/delete
collection /admin/content/crm/membership/periods

Handlers

  • Views data: EntityViewsData (default).
  • Route provider: AdminHtmlRouteProvider.
  • Forms: default/add/edit MembershipPeriodForm, delete ContentEntityDeleteForm.

Notable methods: getMembership(), getApplicableContacts(), isApplicableForContact(Contact $contact), getStartDate(), getEndDate(), isActive(), isExpired().