You are here

class WebformContentCreatorEntity in Webform Content Creator 3.x

Same name and namespace in other branches
  1. 8 src/Entity/WebformContentCreatorEntity.php \Drupal\webform_content_creator\Entity\WebformContentCreatorEntity
  2. 2.x src/Entity/WebformContentCreatorEntity.php \Drupal\webform_content_creator\Entity\WebformContentCreatorEntity

Defines the Webform Content creator entity.

Plugin annotation


@ConfigEntityType(
  id = "webform_content_creator",
  label = @Translation("Webform Content creator"),
  handlers = {
    "list_builder" = "Drupal\webform_content_creator\Controller\WebformContentCreatorListBuilder",
    "form" = {
      "add" = "Drupal\webform_content_creator\Form\WebformContentCreatorForm",
      "edit" = "Drupal\webform_content_creator\Form\WebformContentCreatorForm",
      "delete" = "Drupal\webform_content_creator\Form\WebformContentCreatorDeleteForm",
      "manage_fields" = "Drupal\webform_content_creator\Form\WebformContentCreatorManageFieldsForm",
    }
  },
  config_prefix = "webform_content_creator",
  admin_permission = "administer site configuration",
  entity_keys = {
    "id" = "id",
    "title" = "title",
    "webform" = "webform",
    "content_type" = "content_type",
  },
  links = {
    "manage-fields-form" = "/admin/config/webform_content_creator/manage/{webform_content_creator}/fields",
    "edit-form" = "/admin/config/webform_content_creator/{webform_content_creator}",
    "delete-form" = "/admin/config/webform_content_creator/{webform_content_creator}/delete",
  },
  config_export = {
    "id",
    "title",
    "webform",
    "content_type",
    "field_title",
    "use_encrypt",
    "encryption_profile",
    "sync_content",
    "sync_content_delete",
    "sync_content_node_field",
    "elements",
  }
)

Hierarchy

Expanded class hierarchy of WebformContentCreatorEntity

1 file declares its use of WebformContentCreatorEntity
WebformContentCreatorEntityTest.php in tests/src/Unit/Entity/WebformContentCreatorEntityTest.php

File

src/Entity/WebformContentCreatorEntity.php, line 61

Namespace

Drupal\webform_content_creator\Entity
View source
class WebformContentCreatorEntity extends ConfigEntityBase implements WebformContentCreatorInterface {
  use StringTranslationTrait, MessengerTrait;

  /**
   * Webform content creator entity id.
   *
   * @var string
   */
  protected $id;

  /**
   * Webform content creator entity title.
   *
   * @var string
   */
  protected $title;

  /**
   * Node title.
   *
   * @var string
   */
  protected $field_title;

  /**
   * Webform machine name.
   *
   * @var string
   */
  protected $webform;

  /**
   * Content type machine name.
   *
   * @var string
   */
  protected $content_type;

  /**
   * Mapping between webform submission values and node field values.
   *
   * @var array
   */
  protected $elements;

  /**
   * Use encryption.
   *
   * @var bool
   */
  protected $use_encrypt;

  /**
   * Encryption profile.
   *
   * @var string
   */
  protected $encryption_profile;

  /**
   * Returns the entity title.
   *
   * @return string
   *   The entity title.
   */
  public function getTitle() {
    return $this
      ->get('title');
  }

  /**
   * Sets the entity title.
   *
   * @param string $title
   *   Node title.
   *
   * @return $this
   *   The Webform Content Creator entity.
   */
  public function setTitle($title) {
    $this
      ->set('title', $title);
    return $this;
  }

  /**
   * Returns the entity content type id.
   *
   * @return string
   *   The entity content type.
   */
  public function getContentType() {
    return $this
      ->get('content_type');
  }

  /**
   * Sets the content type entity.
   *
   * @param string $content_type
   *   Content type entity.
   *
   * @return $this
   *   The Webform Content Creator entity.
   */
  public function setContentType($content_type) {
    $this
      ->set('content_type', $content_type);
    return $this;
  }

  /**
   * Returns the entity webform id.
   *
   * @return string
   *   The entity webform.
   */
  public function getWebform() {
    return $this
      ->get('webform');
  }

  /**
   * Sets the entity webform id.
   *
   * @param string $webform
   *   Webform id.
   *
   * @return $this
   *   The Webform Content Creator entity.
   */
  public function setWebform($webform) {
    $this
      ->set('webform', $webform);
    return $this;
  }

  /**
   * Returns the entity attributes as an associative array.
   *
   * @return array
   *   The entity attributes mapping.
   */
  public function getAttributes() {
    return $this
      ->get(WebformContentCreatorInterface::ELEMENTS);
  }

  /**
   * Check if synchronization between nodes and webform submissions is used.
   *
   * @return bool
   *   true, when the synchronization is used. Otherwise, returns false.
   */
  public function getSyncEditContentCheck() {
    return $this
      ->get(WebformContentCreatorInterface::SYNC_CONTENT);
  }

  /**
   * Check if synchronization is used in deletion.
   *
   * @return bool
   *   true, when the synchronization is used. Otherwise, returns false.
   */
  public function getSyncDeleteContentCheck() {
    return $this
      ->get(WebformContentCreatorInterface::SYNC_CONTENT_DELETE);
  }

  /**
   * Get node field in which the webform submission id will be stored.
   *
   * @return string
   *   Field machine name.
   */
  public function getSyncContentField() {
    return $this
      ->get(WebformContentCreatorInterface::SYNC_CONTENT_FIELD);
  }

  /**
   * Returns the encryption method.
   *
   * @return bool
   *   true, when an encryption profile is used. Otherwise, returns false.
   */
  public function getEncryptionCheck() {
    return $this
      ->get(WebformContentCreatorInterface::USE_ENCRYPT);
  }

  /**
   * Returns the encryption profile.
   *
   * @return string
   *   The encryption profile name.
   */
  public function getEncryptionProfile() {
    return $this
      ->get(WebformContentCreatorInterface::ENCRYPTION_PROFILE);
  }

  /**
   * Get node title.
   *
   * @return string
   *   Node title.
   */
  private function getNodeTitle() {

    // Get title.
    if ($this
      ->get(WebformContentCreatorInterface::FIELD_TITLE) !== NULL && $this
      ->get(WebformContentCreatorInterface::FIELD_TITLE) !== '') {
      $title = $this
        ->get(WebformContentCreatorInterface::FIELD_TITLE);
    }
    else {
      $title = \Drupal::entityTypeManager()
        ->getStorage(WebformContentCreatorInterface::WEBFORM)
        ->load($this
        ->get(WebformContentCreatorInterface::WEBFORM))
        ->label();
    }
    return $title;
  }

  /**
   * Get encryption profile name.
   *
   * @return string
   *   Encryption profile name.
   */
  private function getProfileName() {
    $encryption_profile = '';
    $use_encrypt = $this
      ->get(WebformContentCreatorInterface::USE_ENCRYPT);
    if ($use_encrypt) {
      $encryption_profile = \Drupal::service('entity_type.manager')
        ->getStorage(WebformContentCreatorInterface::ENCRYPTION_PROFILE)
        ->load($this
        ->getEncryptionProfile());
    }
    return $encryption_profile;
  }

  /**
   * Get decrypted value with the configured encryption profile.
   *
   * @param string $value
   *   Encrypted value.
   * @param string $profile
   *   Encryption profile name.
   *
   * @return string
   *   Encryption profile used to encrypt/decrypt $value
   */
  private function getDecryptionFromProfile($value, $profile = '') {
    if ($this
      ->getEncryptionCheck()) {
      $result = WebformContentCreatorUtilities::getDecryptedValue($value, $profile);
    }
    else {
      $result = $value;
    }
    return $result;
  }

  /**
   * Use a single mapping to set a Node field value.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $initial_content
   *   Content being mapped with a webform submission.
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   *   Webform submission entity.
   * @param array $fields
   *   Node fields.
   * @param array $webform_fields
   *   Webform fields (flattened).
   * @param array $data
   *   Webform submission data.
   * @param string $encryption_profile
   *   Encryption profile used in Webform encrypt module.
   * @param string $field_id
   *   Node field id.
   * @param array $mapping
   *   Single mapping between node and webform submissions.
   * @param array $attributes
   *   All mapping values between Node and Webform submission values.
   *
   * @return \Drupal\Core\Entity\ContentEntityInterface
   *   Created node.
   */
  private function mapNodeField(ContentEntityInterface $initial_content, WebformSubmissionInterface $webform_submission, array $fields = [], array $webform_fields = [], array $data = [], $encryption_profile = '', $field_id = '', array $mapping = [], array $attributes = []) {
    $content = $initial_content;
    $webform = $webform_submission
      ->getWebform();
    if (!$content
      ->hasField($field_id) || !is_array($mapping)) {
      return $content;
    }

    // Get the field mapping plugin.
    $field_mapping = \Drupal::service('plugin.manager.webform_content_creator.field_mapping')
      ->getPlugin($attributes[$field_id][WebformContentCreatorInterface::FIELD_MAPPING]);
    $component_fields = $field_mapping
      ->getEntityComponentFields($fields[$field_id]);
    $values = [];
    $webform_element = [];
    if (sizeOf($component_fields) > 0) {
      foreach ($component_fields as $component_field) {
        $webform_element[$component_field] = $webform
          ->getElement($mapping[$component_field][WebformContentCreatorInterface::WEBFORM_FIELD], FALSE);

        // If the custom check functionality is active then we do need to evaluate
        // webform fields.
        if ($attributes[$field_id][WebformContentCreatorInterface::CUSTOM_CHECK]) {
          $field_value = WebformContentCreatorUtilities::getTokenValue($mapping[WebformContentCreatorInterface::CUSTOM_VALUE], $encryption_profile, $webform_submission);
        }
        else {
          if (!$attributes[$field_id][WebformContentCreatorInterface::TYPE]) {
            if (!array_key_exists(WebformContentCreatorInterface::WEBFORM_FIELD, $mapping) || !array_key_exists($mapping[WebformContentCreatorInterface::WEBFORM_FIELD], $data)) {
              return $content;
            }
            $field_value = $this
              ->getDecryptionFromProfile($data[$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]], $encryption_profile);
            if ($fields[$field_id]
              ->getType() === 'entity_reference' && (!is_array($field_value) && intval($field_value) === 0)) {
              $content
                ->set($field_id, []);
              return $content;
            }
          }
          else {
            $field_object = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]};
            if ($field_object instanceof EntityReferenceFieldItemList) {
              $field_value = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]}
                ->getValue()[0]['target_id'];
            }
            else {
              $field_value = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]}->value;
            }
          }
        }
        $values[$component_field] = $field_value;
      }
    }
    else {

      // If the custom check functionality is active then we do need to evaluate
      // webform fields.
      if ($attributes[$field_id][WebformContentCreatorInterface::CUSTOM_CHECK]) {
        $field_value = WebformContentCreatorUtilities::getTokenValue($mapping[WebformContentCreatorInterface::CUSTOM_VALUE], $encryption_profile, $webform_submission);
      }
      else {
        if (!$attributes[$field_id][WebformContentCreatorInterface::TYPE]) {
          if (!array_key_exists(WebformContentCreatorInterface::WEBFORM_FIELD, $mapping) || !array_key_exists($mapping[WebformContentCreatorInterface::WEBFORM_FIELD], $data)) {
            return $content;
          }
          $field_value = $this
            ->getDecryptionFromProfile($data[$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]], $encryption_profile);
          if ($fields[$field_id]
            ->getType() === 'entity_reference' && (!is_array($field_value) && intval($field_value) === 0)) {
            $content
              ->set($field_id, []);
            return $content;
          }
        }
        else {
          $field_object = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]};
          if ($field_object instanceof EntityReferenceFieldItemList) {
            $field_value = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]}
              ->getValue()[0]['target_id'];
          }
          else {
            $field_value = $webform_submission->{$mapping[WebformContentCreatorInterface::WEBFORM_FIELD]}->value;
          }
        }
      }
      $values[$field_id] = $field_value;
    }
    if ($fields[$field_id]
      ->getType() == 'datetime') {
      $field_value = $this
        ->convertTimestamp($fields, $field_id, $field_value);
    }

    // Map the field type using the selected field mapping.
    $field_value = $field_mapping
      ->mapEntityField($content, $webform_element, $values, $fields[$field_id]);
    return $content;
  }

  /**
   * Create node from webform submission.
   *
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   *   Webform submission.
   *
   * @return int
   *   Result after saving content.
   */
  public function createNode(WebformSubmissionInterface $webform_submission) {
    $node_title = $this
      ->getNodeTitle();

    // Get webform submission data.
    $data = $webform_submission
      ->getData();
    if (empty($data)) {
      return 0;
    }
    $encryption_profile = $this
      ->getProfileName();

    // Get title.
    $title = WebformContentCreatorUtilities::getTokenValue($node_title, $encryption_profile, $webform_submission);

    // Decode HTML entities, returning them to their original UTF-8 characters.
    $decoded_title = Html::decodeEntities($title);

    // Create new node.
    $content = Node::create([
      WebformContentCreatorInterface::TYPE => $this
        ->getContentType(),
      'title' => $decoded_title,
    ]);

    // Set node fields values.
    $attributes = $this
      ->get(WebformContentCreatorInterface::ELEMENTS);
    $content_type = \Drupal::entityTypeManager()
      ->getStorage('node_type')
      ->load($this
      ->getContentType());
    if (empty($content_type)) {
      return 0;
    }

    // Get the webform fields flattened to identify field types.
    $webform = $webform_submission
      ->getWebform();
    $webform_fields = [];
    if ($webform) {
      $webform_fields = $webform
        ->getElementsDecodedAndFlattened();
    }
    $fields = WebformContentCreatorUtilities::contentTypeFields($content_type);
    if (empty($fields)) {
      return 0;
    }
    foreach ($attributes as $k2 => $v2) {
      $content = $this
        ->mapNodeField($content, $webform_submission, $fields, $webform_fields, $data, $encryption_profile, $k2, $v2, $attributes);
    }
    $result = 0;

    // Save node.
    try {
      $result = $content
        ->save();
    } catch (\Exception $e) {
      \Drupal::logger(WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR)
        ->error($this
        ->t('A problem occurred when creating a new node.'));
      \Drupal::logger(WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR)
        ->error($e
        ->getMessage());
    }
    return $result;
  }

  /**
   * Update node from webform submission.
   *
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   *   Webform submission.
   * @param string $op
   *   Operation.
   *
   * @return int
   *   Result after saving content.
   */
  public function updateNode(WebformSubmissionInterface $webform_submission, $op = 'edit') {
    if (empty($this
      ->getSyncContentField())) {
      return 0;
    }
    $content_type = \Drupal::entityTypeManager()
      ->getStorage('node_type')
      ->load($this
      ->getContentType());
    if (empty($content_type)) {
      return 0;
    }

    // Get the webform fields flattened to identify field types.
    $webform = $webform_submission
      ->getWebform();
    $webform_fields = [];
    if ($webform) {
      $webform_fields = $webform
        ->getElementsDecodedAndFlattened();
    }
    $fields = WebformContentCreatorUtilities::contentTypeFields($content_type);
    if (empty($fields)) {
      return 0;
    }
    if (!array_key_exists($this
      ->getSyncContentField(), $fields)) {
      return 0;
    }
    $node_title = $this
      ->getNodeTitle();

    // Get webform submission data.
    $data = $webform_submission
      ->getData();
    if (empty($data)) {
      return 0;
    }
    $encryption_profile = $this
      ->getProfileName();

    // Get title.
    $title = WebformContentCreatorUtilities::getTokenValue($node_title, $encryption_profile, $webform_submission);

    // Decode HTML entities, returning them to their original UTF-8 characters.
    $decoded_title = Html::decodeEntities($title);

    // Get nodes created from this webform submission.
    $nodes = \Drupal::entityTypeManager()
      ->getStorage('node')
      ->loadByProperties([
      $this
        ->getSyncContentField() => $webform_submission
        ->id(),
    ]);

    // Use only first result, if exists.
    if (!($content = reset($nodes))) {
      return 0;
    }
    if ($op === 'delete' && !empty($this
      ->getSyncDeleteContentCheck())) {
      $result = $content
        ->delete();
      return $result;
    }
    if (empty($this
      ->getSyncEditContentCheck())) {
      return 0;
    }

    // Set title.
    $content
      ->setTitle($decoded_title);

    // Set node fields values.
    $attributes = $this
      ->get(WebformContentCreatorInterface::ELEMENTS);
    foreach ($attributes as $k2 => $v2) {
      $content = $this
        ->mapNodeField($content, $webform_submission, $fields, $webform_fields, $data, $encryption_profile, $k2, $v2, $attributes);
    }
    $result = 0;

    // Save node.
    try {
      $result = $content
        ->save();
    } catch (\Exception $e) {
      \Drupal::logger(WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR)
        ->error($this
        ->t('A problem occurred while updating node.'));
      \Drupal::logger(WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR)
        ->error($e
        ->getMessage());
    }
    return $result;
  }

  /**
   * Check if the content type entity exists.
   *
   * @return bool
   *   True, if content type entity exists. Otherwise, returns false.
   */
  public function existsContentType() {

    // Get content type id.
    $content_type_id = $this
      ->getContentType();

    // Get content type entity.
    $content_type_entity = \Drupal::entityTypeManager()
      ->getStorage('node_type')
      ->load($content_type_id);
    return !empty($content_type_entity);
  }

  /**
   * Check if the content type id is equal to the configured content type.
   *
   * @param string $ct
   *   Content type id.
   *
   * @return bool
   *   True, if the parameter is equal to the content type id of Webform
   *   content creator entity. Otherwise, returns false.
   */
  public function equalsContentType($ct) {
    return $ct === $this
      ->getContentType();
  }

  /**
   * Check if the webform id is equal to the configured webform id.
   *
   * @param string $webform
   *   Webform id.
   *
   * @return bool
   *   True, if the parameter is equal to the webform id of Webform
   *   content creator entity. Otherwise, returns false.
   */
  public function equalsWebform($webform) {
    return $webform === $this
      ->getWebform();
  }

  /**
   * Show a message accordingly to status, after creating/updating an entity.
   *
   * @param int $status
   *   Status int, returned after creating/updating an entity.
   */
  public function statusMessage($status) {
    if ($status) {
      $this
        ->messenger()
        ->addMessage($this
        ->t('Saved the %label entity.', [
        '%label' => $this
          ->getTitle(),
      ]));
    }
    else {
      $this
        ->messenger()
        ->addMessage($this
        ->t('The %label entity was not saved.', [
        '%label' => $this
          ->getTitle(),
      ]));
    }
  }

  /**
   * Convert timestamp value according to field type.
   *
   * @param array $fields
   *   Content type fields.
   * @param string $field_id
   *   Field machine name.
   * @param string $value
   *   Original datetime value.
   *
   * @return string
   *   Converted datetime value.
   */
  public function convertTimestamp(array $fields, $field_id, $field_value) {
    $date_time = new DrupalDateTime($field_value, 'UTC');
    $date_type = $fields[$field_id]
      ->getSettings()['datetime_type'];
    if ($date_type === 'datetime') {
      $result = \Drupal::service('date.formatter')
        ->format($date_time
        ->getTimestamp(), 'custom', DateTimeItemInterface::DATETIME_STORAGE_FORMAT, 'UTC');
    }
    else {
      $result = \Drupal::service('date.formatter')
        ->format($date_time
        ->getTimestamp(), 'custom', DateTimeItemInterface::DATE_STORAGE_FORMAT, 'UTC');
    }
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ConfigEntityBase::$isUninstalling private property Whether the config is being deleted by the uninstall process.
ConfigEntityBase::$langcode protected property The language code of the entity's default language.
ConfigEntityBase::$originalId protected property The original ID of the configuration entity.
ConfigEntityBase::$status protected property The enabled/disabled status of the configuration entity. 4
ConfigEntityBase::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$uuid protected property The UUID for this entity.
ConfigEntityBase::$_core protected property
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::calculateDependencies public function Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityInterface::calculateDependencies 14
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ConfigEntityBase::disable public function Disables the configuration entity. Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Enables the configuration entity. Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Returns the value of a property. Overrides ConfigEntityInterface::get
ConfigEntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityBase::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityBase::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityBase::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides EntityBase::getOriginalId
ConfigEntityBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
ConfigEntityBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
ConfigEntityBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
ConfigEntityBase::getTypedConfig protected function Gets the typed config manager.
ConfigEntityBase::hasTrustedData public function Gets whether on not the data is trusted. Overrides ConfigEntityInterface::hasTrustedData
ConfigEntityBase::invalidateTagsOnDelete protected static function Override to never invalidate the individual entities' cache tags; the config system already invalidates them. Overrides EntityBase::invalidateTagsOnDelete
ConfigEntityBase::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides EntityBase::invalidateTagsOnSave
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides EntityBase::isNew
ConfigEntityBase::isUninstalling public function Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface::isUninstalling
ConfigEntityBase::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityInterface::onDependencyRemoval 8
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete 8
ConfigEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 13
ConfigEntityBase::save public function Saves an entity permanently. Overrides EntityBase::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides EntityBase::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
ConfigEntityBase::setUninstalling public function
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 6
ConfigEntityBase::status public function Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface::status 4
ConfigEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray 2
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct 10
ConfigEntityBase::__sleep public function Overrides EntityBase::__sleep 4
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 2
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. Aliased as: addDependencyTrait
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::access public function Checks data value access. Overrides AccessibleInterface::access 1
EntityBase::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::id public function Gets the identifier. Overrides EntityInterface::id 11
EntityBase::label public function Gets the label of the entity. Overrides EntityInterface::label 6
EntityBase::language public function Gets the language of the entity. Overrides EntityInterface::language 1
EntityBase::languageManager protected function Gets the language manager.
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityInterface::postCreate 4
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 18
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface::postSave 14
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 7
EntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
EntityBase::uuidGenerator protected function Gets the UUID generator.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
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.
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
WebformContentCreatorEntity::$content_type protected property Content type machine name.
WebformContentCreatorEntity::$elements protected property Mapping between webform submission values and node field values.
WebformContentCreatorEntity::$encryption_profile protected property Encryption profile.
WebformContentCreatorEntity::$field_title protected property Node title.
WebformContentCreatorEntity::$id protected property Webform content creator entity id.
WebformContentCreatorEntity::$title protected property Webform content creator entity title.
WebformContentCreatorEntity::$use_encrypt protected property Use encryption.
WebformContentCreatorEntity::$webform protected property Webform machine name.
WebformContentCreatorEntity::convertTimestamp public function Convert timestamp value according to field type.
WebformContentCreatorEntity::createNode public function Create node from webform submission. Overrides WebformContentCreatorInterface::createNode
WebformContentCreatorEntity::equalsContentType public function Check if the content type id is equal to the configured content type. Overrides WebformContentCreatorInterface::equalsContentType
WebformContentCreatorEntity::equalsWebform public function Check if the webform id is equal to the configured webform id. Overrides WebformContentCreatorInterface::equalsWebform
WebformContentCreatorEntity::existsContentType public function Check if the content type entity exists. Overrides WebformContentCreatorInterface::existsContentType
WebformContentCreatorEntity::getAttributes public function Returns the entity attributes as an associative array. Overrides WebformContentCreatorInterface::getAttributes
WebformContentCreatorEntity::getContentType public function Returns the entity content type id. Overrides WebformContentCreatorInterface::getContentType
WebformContentCreatorEntity::getDecryptionFromProfile private function Get decrypted value with the configured encryption profile.
WebformContentCreatorEntity::getEncryptionCheck public function Returns the encryption method. Overrides WebformContentCreatorInterface::getEncryptionCheck
WebformContentCreatorEntity::getEncryptionProfile public function Returns the encryption profile. Overrides WebformContentCreatorInterface::getEncryptionProfile
WebformContentCreatorEntity::getNodeTitle private function Get node title.
WebformContentCreatorEntity::getProfileName private function Get encryption profile name.
WebformContentCreatorEntity::getSyncContentField public function Get node field in which the webform submission id will be stored. Overrides WebformContentCreatorInterface::getSyncContentField
WebformContentCreatorEntity::getSyncDeleteContentCheck public function Check if synchronization is used in deletion. Overrides WebformContentCreatorInterface::getSyncDeleteContentCheck
WebformContentCreatorEntity::getSyncEditContentCheck public function Check if synchronization between nodes and webform submissions is used. Overrides WebformContentCreatorInterface::getSyncEditContentCheck
WebformContentCreatorEntity::getTitle public function Returns the entity title. Overrides WebformContentCreatorInterface::getTitle
WebformContentCreatorEntity::getWebform public function Returns the entity webform id. Overrides WebformContentCreatorInterface::getWebform
WebformContentCreatorEntity::mapNodeField private function Use a single mapping to set a Node field value.
WebformContentCreatorEntity::setContentType public function Sets the content type entity. Overrides WebformContentCreatorInterface::setContentType
WebformContentCreatorEntity::setTitle public function Sets the entity title. Overrides WebformContentCreatorInterface::setTitle
WebformContentCreatorEntity::setWebform public function Sets the entity webform id. Overrides WebformContentCreatorInterface::setWebform
WebformContentCreatorEntity::statusMessage public function Show a message accordingly to status, after creating/updating an entity. Overrides WebformContentCreatorInterface::statusMessage
WebformContentCreatorEntity::updateNode public function Update node from webform submission. Overrides WebformContentCreatorInterface::updateNode
WebformContentCreatorInterface::CUSTOM_CHECK constant
WebformContentCreatorInterface::CUSTOM_VALUE constant
WebformContentCreatorInterface::ELEMENTS constant
WebformContentCreatorInterface::ENCRYPTION_PROFILE constant
WebformContentCreatorInterface::FIELD_MAPPING constant
WebformContentCreatorInterface::FIELD_TITLE constant
WebformContentCreatorInterface::SYNC_CONTENT constant
WebformContentCreatorInterface::SYNC_CONTENT_DELETE constant
WebformContentCreatorInterface::SYNC_CONTENT_FIELD constant
WebformContentCreatorInterface::TYPE constant
WebformContentCreatorInterface::USE_ENCRYPT constant
WebformContentCreatorInterface::WEBFORM constant
WebformContentCreatorInterface::WEBFORM_CONTENT_CREATOR constant
WebformContentCreatorInterface::WEBFORM_FIELD constant