class EntityLegalDocumentVersion in Entity Legal 7.2
Same name and namespace in other branches
- 7 entity_legal.entity.inc \EntityLegalDocumentVersion
 
Legal Document entity version class.
Hierarchy
- class \Entity implements EntityInterface
- class \EntityLegalDocumentVersion
 
 
Expanded class hierarchy of EntityLegalDocumentVersion
1 string reference to 'EntityLegalDocumentVersion'
- entity_legal_entity_info in ./
entity_legal.module  - Implements hook_entity_info().
 
File
- ./
entity_legal.entity.inc, line 344  - Entity API main classes used by entity_legal module.
 
View source
class EntityLegalDocumentVersion extends Entity {
  /**
   * {@inheritdoc}
   */
  public function __construct(array $values = array(), $entity_type = NULL) {
    Entity::__construct($values, ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME);
  }
  /**
   * Get the label of the legal document version entity.
   *
   * @param bool $sanitize
   *   Whether or not to sanitize the label, defaults to TRUE.
   *
   * @return string
   *   The label string.
   */
  public function label($sanitize = FALSE) {
    $label_text = isset($this->label) ? $this->label : '';
    if ($sanitize) {
      $label_text = check_plain($label_text);
    }
    return $label_text;
  }
  /**
   * Get the date for a given entity property.
   *
   * @param string $type
   *   The type of date to retrieve, updated or created.
   *
   * @return string
   *   The formatted date.
   */
  public function getFormattedDate($type = 'updated') {
    switch ($type) {
      case 'updated':
        return format_date($this->updated);
      case 'created':
        return format_date($this->created);
    }
  }
  /**
   * Get the acceptances for this entity legal document version.
   *
   * @param bool|object $account
   *   The Drupal user account to check for, or get all acceptances if FALSE.
   *
   * @return array
   *   The acceptance entities keyed by acceptance id.
   */
  public function getAcceptances($account = FALSE) {
    return entity_get_controller($this->entityType)
      ->getAcceptances($this, $account);
  }
  /**
   * Get attached document entity.
   *
   * @return EntityLegalDocument
   *   The attached document entity.
   */
  public function getDocument() {
    return entity_load_single(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, $this->document_name);
  }
  /**
   * Override buildContent() to add the acceptance form.
   */
  public function buildContent($view_mode = 'full', $langcode = NULL) {
    $content = parent::buildContent($view_mode, $langcode);
    // Get acceptance form or information for the current user.
    $document = $this
      ->getDocument();
    if ($document
      ->userMustAgree() && user_is_logged_in() && !$document
      ->userHasAgreed()) {
      $content['acceptance'] = $document
        ->getAcceptanceForm();
    }
    // Move acceptance to the bottom of the agreement.
    $content['acceptance']['#weight'] = 99;
    return $content;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            Entity:: | 
                  protected | property | 1 | |
| 
            Entity:: | 
                  protected | property | ||
| 
            Entity:: | 
                  protected | property | ||
| 
            Entity:: | 
                  protected | property | ||
| 
            Entity:: | 
                  protected | property | ||
| 
            Entity:: | 
                  public | function | 
            Returns the bundle of the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  protected | function | Defines the entity label if the 'entity_class_label' callback is used. | 1 | 
| 
            Entity:: | 
                  protected | function | Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info(). | |
| 
            Entity:: | 
                  public | function | 
            Permanently deletes the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Returns the info of the type of the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Returns the type of the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Exports the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Gets the raw, translated value of a property or field. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Checks if the entity has a certain exportable status. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Returns the internal, numeric identifier. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Checks whether the entity is the default revision. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Permanently saves the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  protected | function | Set up the object instance on construction or unserializiation. | |
| 
            Entity:: | 
                  public | function | 
            Returns the uri of the entity just as entity_uri(). Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Generate an array for rendering the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | 
            Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface:: | 
                  |
| 
            Entity:: | 
                  public | function | Magic method to only serialize what's necessary. | |
| 
            Entity:: | 
                  public | function | Magic method to invoke setUp() on unserialization. | |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | 
            Override buildContent() to add the acceptance form. Overrides Entity:: | 
                  |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | Get the acceptances for this entity legal document version. | |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | Get attached document entity. | |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | Get the date for a given entity property. | |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | 
            Get the label of the legal document version entity. Overrides Entity:: | 
                  |
| 
            EntityLegalDocumentVersion:: | 
                  public | function | 
            Overrides Entity:: |