You are here

class Registration in Entity Registration 8

Same name and namespace in other branches
  1. 8.2 src/Registration.php \Drupal\registration\Registration

Defines the Registration entity.

Plugin annotation


@ContentEntityType(
  id = "registration",
  label = @Translation("Registration"),
  fieldable = TRUE,
  handlers = {
    "list_builder" = "Drupal\registration\Controller\MailchimpSignupListBuilder",
    "form" = {
      "add" = "Drupal\registration\Form\RegistrationForm",
      "edit" = "Drupal\registration\Form\RegistrationForm",
      "delete" = "Drupal\registration\Form\RegistrationDeleteForm"
    }
  },
  config_prefix = "registration",
  admin_permission = "administer registrations",
  entity_keys = {
    "id" = "registration_id",
    "bundle" = "type",
  },
)

Hierarchy

Expanded class hierarchy of Registration

7 string references to 'Registration'
registration.info.yml in ./registration.info.yml
registration.info.yml
RegistrationWaitlistTestCase::getInfo in modules/registration_waitlist/registration_waitlist.test
RegistrationWaitlistTestCase::testHostRegistrationWaitlistStatus in modules/registration_waitlist/registration_waitlist.test
Check internal status modifiers for the wait list.
registration_entity_info in ./registration.module
Implements hook_entity_info().
registration_menu in ./registration.module
@FIXME This implementation of hook_menu() cannot be automatically converted because it contains logic (i.e., branching statements, function calls, object instantiation, etc.) You will need to convert it manually. Sorry!

... See full list

File

src/Registration.php, line 34

Namespace

Drupal\registration
View source
class Registration extends EntityContentBase implements RegistrationInterface {
  public $registration_id, $type, $entity_id, $entity_type, $anon_mail = NULL, $user_uid = NULL, $count, $author_uid, $state, $created, $updated;

  /**
   * Specifies the default label, which is picked up by label() by default.
   */
  protected function label() {
    $wrapper = entity_metadata_wrapper('registration', $this);
    $host = $wrapper->entity
      ->value();
    if ($host) {
      return t('Registration for !title', array(
        '!title' => $host
          ->label(),
      ));
    }
    return '';
  }

  /**
   * Build content for Registration.
   *
   * @return array
   *   Render array for a registration entity.
   */
  public function buildContent($view_mode = 'full', $langcode = NULL) {
    $build = parent::buildContent($view_mode, $langcode);
    $wrapper = entity_metadata_wrapper('registration', $this);
    $host_entity_type_info = \Drupal::entityManager()
      ->getDefinition($this->entity_type);
    $host_entity = $wrapper->entity
      ->value();
    $state = $wrapper->state
      ->value();
    $author = $wrapper->author
      ->value();
    $user = $wrapper->user
      ->value();
    list(, , $host_entity_bundle) = entity_extract_ids($this->entity_type, $host_entity);
    $host_label = $host_entity
      ->label();
    $host_uri = $host_entity ? entity_uri($this->entity_type, $host_entity) : NULL;
    $build['mail'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('Email Address'),
      '#items' => array(
        array(
          '#markup' => $wrapper->mail
            ->value(),
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
    );

    // Link to host entity.
    $host_entity_link_label = isset($host_entity_type_info['bundles'][$host_entity_bundle]['label']) ? '<div class="field-label">' . $host_entity_type_info['bundles'][$host_entity_bundle]['label'] . '</div>' : '';

    // @FIXME
    // l() expects a Url object, created from a route name or external URI.
    // $build['host_entity_link'] = array(
    //       '#theme' => 'registration_property_field',
    //       '#label' => $host_entity_link_label,
    //       '#items' => array(
    //         array(
    //           '#markup' => l($host_label, $host_uri['path']),
    //         ),
    //       ),
    //       '#classes' => 'field field-label-inline clearfix',
    //     );
    $build['created'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('Created'),
      '#items' => array(
        array(
          '#markup' => format_date($this->created),
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
    );
    $build['updated'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('Updated'),
      '#items' => array(
        array(
          '#markup' => format_date($this->updated),
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
    );
    $build['slots'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('Slots Used'),
      '#items' => array(
        array(
          '#markup' => $this->count,
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
    );
    if ($author) {
      $build['author'] = array(
        '#theme' => 'registration_property_field',
        '#label' => t('Author'),
        '#items' => array(
          array(
            '#markup' => _theme('username', array(
              'account' => $author,
            )),
          ),
        ),
        '#classes' => 'field field-label-inline clearfix',
        '#attributes' => '',
      );
    }
    if ($user) {
      $build['user'] = array(
        '#theme' => 'registration_property_field',
        '#label' => t('User'),
        '#items' => array(
          array(
            '#markup' => _theme('username', array(
              'account' => $user,
            )),
          ),
        ),
        '#classes' => 'field field-label-inline clearfix',
        '#attributes' => '',
      );
    }
    $build['state'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('State'),
      '#items' => array(
        array(
          '#markup' => $state ? filter_xss_admin($state
            ->label()) : '',
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
    );
    return $build;
  }

  /**
   * Save registration.
   *
   * @see entity_save()
   */
  public function save() {

    // Set a default state if not provided.
    $wrapper = entity_metadata_wrapper('registration', $this);
    $state = $wrapper->state
      ->value();
    if (!$state) {
      $default_state = registration_get_default_state($wrapper->type
        ->value());
      if ($default_state) {
        $this->state = $default_state
          ->identifier();
      }
    }
    $this->updated = REQUEST_TIME;
    if (!$this->registration_id && empty($this->created)) {
      $this->created = REQUEST_TIME;
    }
    return parent::save();
  }

  /**
   * Specify URI.
   */
  protected function defaultUri() {
    return array(
      'path' => 'registration/' . $this
        ->internalIdentifier(),
    );
  }

  /**
   * Determine registrant type relative to a given account.
   *
   * @object $account
   *   A Drupal user
   *
   * @return string|NULL
   *   Can be me, user, anon or NULL if account is empty and no anon email set.
   */
  public function registrant_type($account) {
    $reg_type = NULL;
    if (!empty($account)) {
      if ($account->uid && $account->uid === $this->user_uid) {
        $reg_type = REGISTRATION_REGISTRANT_TYPE_ME;
      }
      elseif ($this->user_uid) {
        $reg_type = REGISTRATION_REGISTRANT_TYPE_USER;
      }
    }
    if (!empty($this->anon_mail)) {
      $reg_type = REGISTRATION_REGISTRANT_TYPE_ANON;
    }
    return $reg_type;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 9
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. 34
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. 34
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 27
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency.
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
DestinationBase::$migration protected property The migration.
DestinationBase::$rollbackAction protected property The rollback action to be saved for the last imported item.
DestinationBase::$supportsRollback protected property Indicates whether the destination can be rolled back.
DestinationBase::checkRequirements public function Checks if requirements for this plugin are OK. Overrides RequirementsInterface::checkRequirements
DestinationBase::getDestinationModule public function Gets the destination module handling the destination data. Overrides MigrateDestinationInterface::getDestinationModule 1
DestinationBase::rollbackAction public function The rollback action for the last imported item. Overrides MigrateDestinationInterface::rollbackAction
DestinationBase::setRollbackAction protected function For a destination item being updated, set the appropriate rollback action.
DestinationBase::supportsRollback public function Whether the destination can be rolled back or not. Overrides MigrateDestinationInterface::supportsRollback
Entity::$bundles protected property The list of the bundles of this entity type.
Entity::$storage protected property The entity storage.
Entity::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
Entity::fields public function Returns an array of destination fields. Overrides MigrateDestinationInterface::fields
Entity::getBundle public function Gets the bundle for the row taking into account the default.
Entity::getEntity protected function Creates or loads an entity. 5
Entity::getEntityId protected function Gets the entity ID of the row. 2
Entity::getKey protected function Returns a specific entity key.
EntityChangedInterface::getChangedTime public function Gets the timestamp of the last entity change for the current translation.
EntityChangedInterface::getChangedTimeAcrossTranslations public function Gets the timestamp of the last entity change across all translations.
EntityChangedInterface::setChangedTime public function Sets the timestamp of the last entity change for the current translation.
EntityContentBase::$deprecatedProperties protected property
EntityContentBase::$entityFieldManager protected property Entity field manager.
EntityContentBase::$fieldTypeManager protected property Field type plugin manager.
EntityContentBase::create public static function Creates an instance of the plugin. Overrides Entity::create 2
EntityContentBase::getHighestId public function Returns the highest ID tracked by the implementing plugin. Overrides HighestIdInterface::getHighestId 2
EntityContentBase::getIds public function Gets the destination IDs. Overrides MigrateDestinationInterface::getIds 2
EntityContentBase::import public function Overrides MigrateDestinationInterface::import 3
EntityContentBase::isEntityValidationRequired public function Returns a state of whether an entity needs to be validated before saving. Overrides MigrateValidatableEntityInterface::isEntityValidationRequired
EntityContentBase::isTranslationDestination public function
EntityContentBase::processStubRow protected function Populates as much of the stub row as possible. 3
EntityContentBase::rollback public function Delete the specified destination object from the target Drupal. Overrides Entity::rollback 1
EntityContentBase::updateEntity protected function Updates an entity with the new values from row. 3
EntityContentBase::validateEntity public function Validates the entity. Overrides MigrateValidatableEntityInterface::validateEntity
EntityContentBase::__construct public function Constructs a content entity. Overrides Entity::__construct 3
EntityFieldDefinitionTrait::getDefinitionFromEntity protected function Gets the field definition from a specific entity base field.
EntityFieldDefinitionTrait::getEntityTypeId protected static function Finds the entity type from configuration or plugin ID. 5
EntityInterface::bundle public function Gets the bundle of the entity. 2
EntityInterface::createDuplicate public function Creates a duplicate of the entity. 2
EntityInterface::delete public function Deletes an entity permanently. 2
EntityInterface::enforceIsNew public function Enforces an entity to be new. 2
EntityInterface::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. 2
EntityInterface::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. 2
EntityInterface::getConfigDependencyName public function Gets the configuration dependency name. 2
EntityInterface::getConfigTarget public function Gets the configuration target identifier for the entity. 2
EntityInterface::getEntityType public function Gets the entity type definition. 2
EntityInterface::getOriginalId public function Gets the original ID. 2
EntityInterface::getTypedData public function Gets a typed data object for this entity object. 2
EntityInterface::hasLinkTemplate public function Indicates if a link template exists for a given key. 2
EntityInterface::id public function Gets the identifier. 2
EntityInterface::isNew public function Determines whether the entity is new. 2
EntityInterface::language public function Gets the language of the entity. 2
EntityInterface::link Deprecated public function Deprecated way of generating a link to the entity. See toLink(). 2
EntityInterface::load public static function Loads an entity. 2
EntityInterface::loadMultiple public static function Loads one or more entities. 2
EntityInterface::postCreate public function Acts on a created entity before hooks are invoked. 2
EntityInterface::postDelete public static function Acts on deleted entities before the delete hook is invoked. 2
EntityInterface::postLoad public static function Acts on loaded entities. 3
EntityInterface::postSave public function Acts on a saved entity before the insert or update hook is invoked. 2
EntityInterface::preCreate public static function Changes the values of an entity before it is created. 2
EntityInterface::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. 2
EntityInterface::preSave public function Acts on an entity before the presave hook is invoked. 2
EntityInterface::referencedEntities public function Gets a list of entities referenced by this entity. 2
EntityInterface::setOriginalId public function Sets the original ID. 2
EntityInterface::toLink public function Generates the HTML for a link to this entity. 2
EntityInterface::toUrl public function Gets the URL object for the entity. 2
EntityInterface::uriRelationships public function Gets a list of URI relationships supported by this entity. 2
EntityInterface::url Deprecated public function Gets the public URL for this entity. 2
EntityInterface::urlInfo Deprecated public function Gets the URL object for the entity. 2
EntityInterface::uuid public function Gets the entity UUID (Universally Unique Identifier). 2
EntityOwnerInterface::getOwner public function Returns the entity owner's user entity. 1
EntityOwnerInterface::getOwnerId public function Returns the entity owner's user ID. 1
EntityOwnerInterface::setOwner public function Sets the entity owner's user entity. 1
EntityOwnerInterface::setOwnerId public function Sets the entity owner's user ID. 1
FieldableEntityInterface::baseFieldDefinitions public static function Provides base field definitions for an entity type. 2
FieldableEntityInterface::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. 2
FieldableEntityInterface::get public function Gets a field item list. 1
FieldableEntityInterface::getFieldDefinition public function Gets the definition of a contained field. 1
FieldableEntityInterface::getFieldDefinitions public function Gets an array of field definitions of all contained fields. 1
FieldableEntityInterface::getFields public function Gets an array of all field item lists. 1
FieldableEntityInterface::getTranslatableFields public function Gets an array of field item lists for translatable fields. 1
FieldableEntityInterface::hasField public function Determines whether the entity has a field with the given name. 1
FieldableEntityInterface::isValidationRequired public function Checks whether entity validation is required before saving the entity. 1
FieldableEntityInterface::onChange public function Reacts to changes to a field. 1
FieldableEntityInterface::set public function Sets a field value. 1
FieldableEntityInterface::setValidationRequired public function Sets whether entity validation is required before saving the entity. 1
FieldableEntityInterface::toArray public function Gets an array of all field values. Overrides EntityInterface::toArray
FieldableEntityInterface::validate public function Validates the currently set values. 1
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
RefinableCacheableDependencyInterface::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. 1
RefinableCacheableDependencyInterface::addCacheContexts public function Adds cache contexts. 1
RefinableCacheableDependencyInterface::addCacheTags public function Adds cache tags. 1
RefinableCacheableDependencyInterface::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. 1
Registration::$registration_id public property
Registration::buildContent public function Build content for Registration.
Registration::defaultUri protected function Specify URI.
Registration::label protected function Specifies the default label, which is picked up by label() by default. Overrides EntityInterface::label
Registration::registrant_type public function Determine registrant type relative to a given account.
Registration::save public function Save registration. Overrides EntityContentBase::save
RevisionableInterface::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. 1
RevisionableInterface::getRevisionId public function Gets the revision identifier of the entity. 1
RevisionableInterface::isDefaultRevision public function Checks if this entity is the default revision. 1
RevisionableInterface::isLatestRevision public function Checks if this entity is the latest revision. 1
RevisionableInterface::isNewRevision public function Determines whether a new revision should be created on save. 1
RevisionableInterface::preSaveRevision public function Acts on a revision before it gets saved. 1
RevisionableInterface::setNewRevision public function Enforces an entity to be saved as a new revision. 1
RevisionableInterface::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. 1
RevisionableInterface::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. 1
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
SynchronizableInterface::isSyncing public function Returns whether this entity is being changed as part of a synchronization. 1
SynchronizableInterface::setSyncing public function Sets the status of the synchronization flag. 1
TranslatableInterface::addTranslation public function Adds a new translation to the translatable object. 1
TranslatableInterface::getTranslation public function Gets a translation of the data. 1
TranslatableInterface::getTranslationLanguages public function Returns the languages the data is translated to. 1
TranslatableInterface::getUntranslated public function Returns the translatable object referring to the original language. 1
TranslatableInterface::hasTranslation public function Checks there is a translation for the given language code. 1
TranslatableInterface::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. 1
TranslatableInterface::isDefaultTranslation public function Checks whether the translation is the default one. 1
TranslatableInterface::isNewTranslation public function Checks whether the translation is new. 1
TranslatableInterface::isTranslatable public function Returns the translation support status. 1
TranslatableInterface::removeTranslation public function Removes the translation identified by the given language code. 1
TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. 1
TranslatableRevisionableInterface::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. 1
TranslatableRevisionableInterface::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. 1
TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. 1
TranslatableRevisionableInterface::setRevisionTranslationAffected public function Marks the current revision translation as affected. 1
TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. 1