You are here

EntityformType.php in Entityform 8.3

File

src/Entity/EntityformType.php
View source
<?php

/**
 * @file
 * Contains \Drupal\entityform\Entity\EntityformType.
 */
namespace Drupal\entityform\Entity;

use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\EntityStorageInterface;

/**
 * Defines the Entityform type configuration entity.
 *
 * @ConfigEntityType(
 *   id = "entityform_type",
 *   label = @Translation("Entityform type"),
 *   handlers = {
 *     "access" = "Drupal\Core\Entity\EntityAccessControlHandler",
 *     "form" = {
 *       "add" = "Drupal\entityform\EntityformTypeForm",
 *       "edit" = "Drupal\entityform\EntityformTypeForm",
 *     },
 *     "list_builder" = "Drupal\entityform\EntityformTypeListBuilder",
 *   },
 *   admin_permission = "administer entityform types",
 *   config_prefix = "type",
 *   bundle_of = "entityform_submission",
 *   entity_keys = {
 *     "id" = "type",
 *     "label" = "name",
 *   },
 *   links = {
 *     "delete-form" = "entityform.entityformtype_delete",
 *     "edit-form" = "entityform.entityformtype_edit",
 *     "collection" = "/admin/structure/entityform_types",
 *   }
 * )
 */
class EntityformType extends ConfigEntityBundleBase {

  /**
   * Closed status for a form.
   */
  const STATUS_CLOSED = 'ENTITYFORM_CLOSED';

  /**
   * Open status for a form.
   */
  const STATUS_OPEN = 'ENTITYFORM_OPEN';
  const RESUBMIT_ACTION_OLD = 'ENTITYFORM_RESUBMIT_OLD';
  const RESUBMIT_ACTION_NEW = 'ENTITYFORM_RESUBMIT_NEW';
  const RESUBMIT_ACTION_DISALLOW = 'ENTITYFORM_RESUBMIT_DISALLOW';
  const RESUBMIT_ACTION_CONFIRM = 'ENTITYFORM_RESUBMIT_CONFIRM';

  /**
   * The machine name of this entityform type.
   *
   * @var string
   *
   * @todo Rename to $id.
   */
  public $type;
  public $preview_page = 0;

  /**
   * The human-readable name of the entityform type.
   *
   * @var string
   *
   * @todo Rename to $label.
   */
  public $name;

  /**
   * The title to use for the form.
   *
   * @var string
   */
  public $form_title = 'Title';

  /**
   * A brief description of this entityform type.
   *
   * @var string
   */
  public $description;

  /**
   * Help information shown to the user when creating a Entityform of this type.
   *
   * @var string
   */
  public $help;

  /**
   * Current status of the form. Currently only closed or open.
   * @var string;
   */
  public $form_status;

  /**
   * Roles @todo text
   * @var array;
   */
  public $roles;

  /**
   * @var string;
   */
  public $resubmit_action;

  /**
   * Module-specific settings for this entityform type, keyed by module name.
   *
   * @var array
   *
   * @todo Pluginify.
   */
  public $settings = array();

  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this->type;
  }

  /**
   * {@inheritdoc}
   */
  public function getModuleSettings($module) {
    if (isset($this->settings[$module]) && is_array($this->settings[$module])) {
      return $this->settings[$module];
    }
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function isLocked() {
    $locked = \Drupal::state()
      ->get('entityform.type.locked');
    return isset($locked[$this
      ->id()]) ? $locked[$this
      ->id()] : FALSE;
  }

}

Classes

Namesort descending Description
EntityformType Defines the Entityform type configuration entity.