You are here

class YamlForm in YAML Form 8

Defines the form entity.

Plugin annotation


@ConfigEntityType(
  id = "yamlform",
  label = @Translation("Form"),
  handlers = {
    "storage" = "\Drupal\yamlform\YamlFormEntityStorage",
    "view_builder" = "Drupal\yamlform\YamlFormEntityViewBuilder",
    "list_builder" = "Drupal\yamlform\YamlFormEntityListBuilder",
    "access" = "Drupal\yamlform\YamlFormEntityAccessControlHandler",
    "form" = {
      "default" = "Drupal\yamlform\YamlFormEntityForm",
      "settings" = "Drupal\yamlform\YamlFormEntitySettingsForm",
      "third_party_settings" = "Drupal\yamlform\YamlFormEntityThirdPartySettingsForm",
      "assets" = "Drupal\yamlform\YamlFormEntityAssetsForm",
      "access" = "Drupal\yamlform\YamlFormEntityAccessForm",
      "handlers" = "Drupal\yamlform\YamlFormEntityHandlersForm",
      "delete" = "Drupal\yamlform\YamlFormEntityDeleteForm",
      "duplicate" = "Drupal\yamlform\YamlFormEntityForm",
    }
  },
  admin_permission = "administer yamlform",
  bundle_of = "yamlform_submission",
  entity_keys = {
    "id" = "id",
    "label" = "title",
  },
  links = {
    "canonical" = "/yamlform/{yamlform}",
    "submissions" = "/yamlform/{yamlform}/submissions",
    "add-form" = "/yamlform/{yamlform}",
    "test-form" = "/yamlform/{yamlform}/test",
    "edit-form" = "/admin/structure/yamlform/manage/{yamlform}",
    "settings-form" = "/admin/structure/yamlform/manage/{yamlform}/settings",
    "assets-form" = "/admin/structure/yamlform/manage/{yamlform}/assets",
    "third-party-settings-form" = "/admin/structure/yamlform/manage/{yamlform}/third-party",
    "access-form" = "/admin/structure/yamlform/manage/{yamlform}/access",
    "handlers-form" = "/admin/structure/yamlform/manage/{yamlform}/handlers",
    "duplicate-form" = "/admin/structure/yamlform/manage/{yamlform}/duplicate",
    "delete-form" = "/admin/structure/yamlform/manage/{yamlform}/delete",
    "export-form" = "/admin/structure/yamlform/manage/{yamlform}/export",
    "results-submissions" = "/admin/structure/yamlform/manage/{yamlform}/results/submissions",
    "results-table" = "/admin/structure/yamlform/manage/{yamlform}/results/table",
    "results-export" = "/admin/structure/yamlform/manage/{yamlform}/results/download",
    "results-clear" = "/admin/structure/yamlform/manage/{yamlform}/results/clear",
    "collection" = "/admin/structure/yamlform",
  },
  config_export = {
    "status",
    "uid",
    "template",
    "id",
    "uuid",
    "title",
    "description",
    "elements",
    "css",
    "javascript",
    "settings",
    "access",
    "handlers",
    "third_party_settings",
  },
)

Hierarchy

Expanded class hierarchy of YamlForm

42 files declare their use of YamlForm
yamlform.drush.inc in drush/yamlform.drush.inc
YAML Form module drush commands.
yamlform.install in ./yamlform.install
Install, update and uninstall functions for the YAML Form module.
yamlform.module in ./yamlform.module
Enables the creation of forms and questionnaires.
yamlform.translation.inc in includes/yamlform.translation.inc
YAML Form module translation hooks.
yamlform.update.inc in includes/yamlform.update.inc
YAML Form module update hooks.

... See full list

2 string references to 'YamlForm'
YamlFormToWebformMigrateManager::replace in modules/yamlform_to_webform/src/YamlFormToWebformMigrateManager.php
Search-n-replace YAML form variations in string with the Webform namespace.
_drush_yamform_to_webform_rename in modules/yamlform_to_webform/yamlform_to_webform.drush.inc
Rename all file from YAML Form to Webform.

File

src/Entity/YamlForm.php, line 86

Namespace

Drupal\yamlform\Entity
View source
class YamlForm extends ConfigEntityBundleBase implements YamlFormInterface {
  use StringTranslationTrait;

  /**
   * The form ID.
   *
   * @var string
   */
  protected $id;

  /**
   * The form UUID.
   *
   * @var string
   */
  protected $uuid;

  /**
   * The form status.
   *
   * @var bool
   */
  protected $status = TRUE;

  /**
   * The form template indicator.
   *
   * @var bool
   */
  protected $template = FALSE;

  /**
   * The form title.
   *
   * @var string
   */
  protected $title;

  /**
   * The form description.
   *
   * @var string
   */
  protected $description;

  /**
   * The owner's uid.
   *
   * @var int
   */
  protected $uid;

  /**
   * The form settings.
   *
   * @var array
   */
  protected $settings = [];

  /**
   * The form access controls.
   *
   * @var array
   */
  protected $access = [];

  /**
   * The form elements.
   *
   * @var string
   */
  protected $elements;

  /**
   * The CSS stylesheet.
   *
   * @var string
   */
  protected $css = '';

  /**
   * The JavaScript.
   *
   * @var string
   */
  protected $javascript = '';

  /**
   * The array of form handlers for this form.
   *
   * @var array
   */
  protected $handlers = [];

  /**
   * Holds the collection of form handlers that are used by this form.
   *
   * @var \Drupal\yamlform\YamlFormHandlerPluginCollection
   */
  protected $handlersCollection;

  /**
   * The form elements original.
   *
   * @var string
   */
  protected $elementsOriginal;

  /**
   * The form elements decoded.
   *
   * @var array
   */
  protected $elementsDecoded;

  /**
   * The form elements initializes (and decoded).
   *
   * @var array
   */
  protected $elementsInitialized;

  /**
   * The form elements decoded and flattened.
   *
   * @var array
   */
  protected $elementsDecodedAndFlattened;

  /**
   * The form elements initialized and flattened.
   *
   * @var array
   */
  protected $elementsInitializedAndFlattened;

  /**
   * The form elements flattened and has value.
   *
   * @var array
   */
  protected $elementsFlattenedAndHasValue;

  /**
   * The form elements translations.
   *
   * @var array
   */
  protected $elementsTranslations;

  /**
   * The form pages.
   *
   * @var array
   */
  protected $pages;

  /**
   * Track if the form has a managed file (upload) element.
   *
   * @var bool
   */
  protected $hasManagedFile = FALSE;

  /**
   * Track if the form is using a flexbox layout.
   *
   * @var bool
   */
  protected $hasFlexboxLayout = FALSE;

  /**
   * Track if the form has translations.
   *
   * @var bool
   */
  protected $hasTranslations;

  /**
   * {@inheritdoc}
   */
  public function getOwner() {
    return $this->uid ? User::load($this->uid) : NULL;
  }

  /**
   * Sets the entity owner's user entity.
   *
   * @param \Drupal\user\UserInterface $account
   *   The owner user entity.
   *
   * @return $this
   */
  public function setOwner(UserInterface $account) {
    $this->uid = $account
      ->id();
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setOwnerId($uid) {
    $this->uid = $uid ? $uid : NULL;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function isOpen() {
    return $this->status ? TRUE : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function isClosed() {
    return !$this
      ->isOpen();
  }

  /**
   * {@inheritdoc}
   */
  public function isTemplate() {
    return $this->template ? TRUE : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function isConfidential() {
    return $this
      ->getSetting('form_confidential');
  }

  /**
   * {@inheritdoc}
   */
  public function hasSubmissions() {

    /** @var \Drupal\yamlform\YamlFormSubmissionStorageInterface $submission_storage */
    $submission_storage = \Drupal::entityTypeManager()
      ->getStorage('yamlform_submission');
    return $submission_storage
      ->getTotal($this) ? TRUE : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function hasTranslations() {
    if (isset($this->hasTranslations)) {
      return $this->hasTranslations;
    }

    // Make sure the config translation module is enabled.
    if (!\Drupal::moduleHandler()
      ->moduleExists('config_translation')) {
      $this->hasTranslations = FALSE;
      return $this->hasTranslations;
    }

    /** @var \Drupal\locale\LocaleConfigManager $local_config_manager */
    $local_config_manager = \Drupal::service('locale.config_manager');
    $languages = \Drupal::languageManager()
      ->getLanguages();
    foreach ($languages as $langcode => $language) {
      if ($local_config_manager
        ->hasTranslation('yamlform.yamlform.' . $this
        ->id(), $langcode)) {
        $this->hasTranslations = TRUE;
        return $this->hasTranslations;
      }
    }
    $this->hasTranslations = FALSE;
    return $this->hasTranslations;
  }

  /**
   * {@inheritdoc}
   */
  public function hasPage() {
    $settings = $this
      ->getSettings();
    return $settings['page'] ? TRUE : FALSE;
  }

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

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

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

  /**
   * {@inheritdoc}
   */
  public function setDescription($description) {
    $this->description = $description;
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setCss($css) {
    $this->css = $css;
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setJavaScript($javascript) {
    $this->javascript = $javascript;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSettings() {
    return $this->settings + self::getDefaultSettings();
  }

  /**
   * {@inheritdoc}
   */
  public function setSettings(array $settings) {

    // Always apply the default settings.
    $this->settings = self::getDefaultSettings();

    // Now apply custom settings.
    foreach ($settings as $name => $value) {
      $this->settings[$name] = $value;
    }
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getSetting($key) {
    $settings = $this
      ->getSettings();
    return isset($settings[$key]) ? $settings[$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setSetting($key, $value) {
    $settings = $this
      ->getSettings();
    $settings[$key] = $value;
    $this
      ->setSettings($settings);
    return $this;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setAccessRules(array $access) {
    $this->access = $access;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public static function getDefaultSettings() {
    return [
      'page' => TRUE,
      'page_submit_path' => '',
      'page_confirm_path' => '',
      'form_submit_label' => '',
      'form_submit_attributes' => [],
      'form_exception_message' => '',
      'form_closed_message' => '',
      'form_confidential' => FALSE,
      'form_confidential_message' => '',
      'form_prepopulate' => FALSE,
      'form_prepopulate_source_entity' => FALSE,
      'form_novalidate' => FALSE,
      'form_unsaved' => FALSE,
      'form_disable_back' => FALSE,
      'form_autofocus' => FALSE,
      'form_details_toggle' => FALSE,
      'wizard_progress_bar' => TRUE,
      'wizard_progress_pages' => FALSE,
      'wizard_progress_percentage' => FALSE,
      'wizard_next_button_label' => '',
      'wizard_next_button_attributes' => [],
      'wizard_prev_button_label' => '',
      'wizard_prev_button_attributes' => [],
      'wizard_start_label' => '',
      'wizard_complete' => TRUE,
      'wizard_complete_label' => '',
      'preview' => DRUPAL_DISABLED,
      'preview_next_button_label' => '',
      'preview_next_button_attributes' => [],
      'preview_prev_button_label' => '',
      'preview_prev_button_attributes' => [],
      'preview_message' => '',
      'draft' => FALSE,
      'draft_auto_save' => FALSE,
      'draft_button_label' => '',
      'draft_button_attributes' => [],
      'draft_saved_message' => '',
      'draft_loaded_message' => '',
      'confirmation_type' => 'page',
      'confirmation_message' => '',
      'confirmation_url' => '',
      'confirmation_attributes' => [],
      'confirmation_back' => TRUE,
      'confirmation_back_label' => '',
      'confirmation_back_attributes' => [],
      'limit_total' => NULL,
      'limit_total_message' => '',
      'limit_user' => NULL,
      'limit_user_message' => '',
      'entity_limit_total' => NULL,
      'entity_limit_user' => NULL,
      'results_disabled' => FALSE,
      'results_disabled_ignore' => FALSE,
      'token_update' => FALSE,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function getDefaultAccessRules() {
    return [
      'create' => [
        'roles' => [
          'anonymous',
          'authenticated',
        ],
        'users' => [],
      ],
      'view_any' => [
        'roles' => [],
        'users' => [],
      ],
      'update_any' => [
        'roles' => [],
        'users' => [],
      ],
      'delete_any' => [
        'roles' => [],
        'users' => [],
      ],
      'purge_any' => [
        'roles' => [],
        'users' => [],
      ],
      'view_own' => [
        'roles' => [],
        'users' => [],
      ],
      'update_own' => [
        'roles' => [],
        'users' => [],
      ],
      'delete_own' => [
        'roles' => [],
        'users' => [],
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function checkAccessRules($operation, AccountInterface $account, YamlFormSubmissionInterface $yamlform_submission = NULL) {

    // Always grant access to "admin" which are form and form
    // submission administrators.
    if ($account
      ->hasPermission('administer yamlform') || $account
      ->hasPermission('administer yamlform submission')) {
      return TRUE;
    }

    // The "page" operation is the same as "create" but requires that the
    // Form is allowed to be displayed as dedicated page.
    // Used by the 'entity.yamlform.canonical' route.
    if ($operation == 'page') {
      if (empty($this->settings['page'])) {
        return FALSE;
      }
      else {
        $operation = 'create';
      }
    }
    $access_rules = $this
      ->getAccessRules();
    if (isset($access_rules[$operation]) && in_array($operation, [
      'create',
      'view_any',
      'update_any',
      'delete_any',
      'purge_any',
      'view_own',
    ]) && $this
      ->checkAccessRule($access_rules[$operation], $account)) {
      return TRUE;
    }
    elseif (isset($access_rules[$operation . '_any']) && $this
      ->checkAccessRule($access_rules[$operation . '_any'], $account)) {
      return TRUE;
    }
    elseif (isset($access_rules[$operation . '_own']) && $account
      ->isAuthenticated() && $yamlform_submission && $account
      ->id() === $yamlform_submission
      ->getOwnerId() && $this
      ->checkAccessRule($access_rules[$operation . '_own'], $account)) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

  /**
   * Checks an access rule against a user account's roles and id.
   *
   * @param array $access_rule
   *   An access rule.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The user session for which to check access.
   *
   * @return bool
   *   The access result. Returns a TRUE if access is allowed.
   */
  protected function checkAccessRule(array $access_rule, AccountInterface $account) {
    if (!empty($access_rule['roles']) && array_intersect($access_rule['roles'], $account
      ->getRoles())) {
      return TRUE;
    }
    elseif (!empty($access_rule['users']) && in_array($account
      ->id(), $access_rule['users'])) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getSubmissionForm(array $values = [], $operation = 'default') {

    // Set this form's id.
    $values['yamlform_id'] = $this
      ->id();
    $yamlform_submission = $this
      ->entityTypeManager()
      ->getStorage('yamlform_submission')
      ->create($values);
    return \Drupal::service('entity.form_builder')
      ->getForm($yamlform_submission, $operation);
  }

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

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

  /**
   * {@inheritdoc}
   */
  public function getElementsDecoded() {
    $this
      ->initElements();
    return $this->elementsDecoded;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementsInitialized() {
    $this
      ->initElements();
    return $this->elementsInitialized;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementsInitializedAndFlattened() {
    $this
      ->initElements();
    return $this->elementsInitializedAndFlattened;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementsDecodedAndFlattened() {
    $this
      ->initElements();
    return $this->elementsDecodedAndFlattened;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementsFlattenedAndHasValue() {
    $this
      ->initElements();
    return $this->elementsFlattenedAndHasValue;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementsSelectorOptions() {

    /** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
    $element_manager = \Drupal::service('plugin.manager.yamlform.element');
    $selectors = [];
    $elements = $this
      ->getElementsInitializedAndFlattened();
    foreach ($elements as $element) {
      $element_handler = $element_manager
        ->getElementInstance($element);
      $selectors += $element_handler
        ->getElementSelectorOptions($element);
    }
    return $selectors;
  }

  /**
   * {@inheritdoc}
   */
  public function setElements(array $elements) {
    $this->elements = Yaml::encode($elements);
    $this
      ->resetElements();
    return $this;
  }

  /**
   * Initialize parse form elements.
   */
  protected function initElements() {
    if (isset($this->elementsInitialized)) {
      return;
    }
    $this->elementsDecodedAndFlattened = [];
    $this->elementsInitializedAndFlattened = [];
    $this->elementsFlattenedAndHasValue = [];
    $this->elementsTranslations = [];
    try {

      /** @var \Drupal\yamlform\YamlFormTranslationManagerInterface $translation_manager */
      $translation_manager = \Drupal::service('yamlform.translation_manager');

      /** @var \Drupal\Core\Language\LanguageManagerInterface $language_manager */
      $language_manager = \Drupal::service('language_manager');

      // If current form is translated, load the base (default) form and apply
      // the translation to the elements.
      if ($this->langcode != $language_manager
        ->getCurrentLanguage()
        ->getId()) {
        $default_langcode = $language_manager
          ->getDefaultLanguage()
          ->getId();
        $elements = $translation_manager
          ->getConfigElements($this, $default_langcode);
        $this->elementsTranslations = Yaml::decode($this->elements);
      }
      else {
        $elements = Yaml::decode($this->elements);
      }

      // Since YAML supports simple values.
      $elements = is_array($elements) ? $elements : [];
      $this->elementsDecoded = $elements;
    } catch (\Exception $exception) {
      $link = $this
        ->link(t('Edit'), 'edit-form');
      \Drupal::logger('yamlform')
        ->notice('%title elements are not valid. @message', [
        '%title' => $this
          ->label(),
        '@message' => $exception
          ->getMessage(),
        'link' => $link,
      ]);
      $elements = FALSE;
    }
    if ($elements !== FALSE) {
      $this
        ->initElementsRecursive($elements);
      $this
        ->invokeHandlers('alterElements', $elements, $this);
    }
    $this->elementsInitialized = $elements;
  }

  /**
   * Reset parsed and cached form elements.
   */
  protected function resetElements() {
    $this->elementsDecoded = NULL;
    $this->elementsInitialized = NULL;
    $this->elementsDecodedAndFlattened = NULL;
    $this->elementsInitializedAndFlattened = NULL;
    $this->elementsFlattenedAndHasValue = NULL;
    $this->elementsTranslations = NULL;
  }

  /**
   * Initialize form elements into a flatten array.
   *
   * @param array $elements
   *   The form elements.
   */
  protected function initElementsRecursive(array &$elements, $parent = '', $depth = 0) {

    /** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
    $element_manager = \Drupal::service('plugin.manager.yamlform.element');

    /** @var \Drupal\Core\Render\ElementInfoManagerInterface $element_info */
    $element_info = \Drupal::service('plugin.manager.element_info');

    // Remove ignored properties.
    $elements = YamlFormElementHelper::removeIgnoredProperties($elements);
    foreach ($elements as $key => &$element) {
      if (Element::property($key) || !is_array($element)) {
        continue;
      }

      // Apply translation to element.
      if (isset($this->elementsTranslations[$key])) {
        YamlFormElementHelper::applyTranslation($element, $this->elementsTranslations[$key]);
      }

      // Copy only the element properties to decoded and flattened elements.
      $this->elementsDecodedAndFlattened[$key] = YamlFormElementHelper::getProperties($element);

      // Set id, key, parent_key, depth, and parent children.
      $element['#yamlform_id'] = $this
        ->id() . '--' . $key;
      $element['#yamlform_key'] = $key;
      $element['#yamlform_parent_key'] = $parent;
      $element['#yamlform_parent_flexbox'] = FALSE;
      $element['#yamlform_depth'] = $depth;
      $element['#yamlform_children'] = [];
      $element['#yamlform_multiple'] = FALSE;
      $element['#yamlform_composite'] = FALSE;
      if (!empty($parent)) {
        $parent_element = $this->elementsInitializedAndFlattened[$parent];

        // Add element to the parent element's children.
        $parent_element['#yamlform_children'][$key] = $key;

        // Set #parent_flexbox to TRUE is the parent element is a
        // 'yamlform_flexbox'.
        $element['#yamlform_parent_flexbox'] = isset($parent_element['#type']) && $parent_element['#type'] == 'yamlform_flexbox' ? TRUE : FALSE;
      }

      // Set #title and #admin_title to NULL if it is not defined.
      $element += [
        '#title' => NULL,
        '#admin_title' => NULL,
      ];

      // If #private set #access.
      if (!empty($element['#private'])) {
        $element['#access'] = $this
          ->access('submission_view_any');
      }
      $element_handler = NULL;
      if (isset($element['#type'])) {

        // Track managed file upload.
        if ($element['#type'] == 'managed_file') {
          $this->hasManagedFile = TRUE;
        }

        // Track flexbox.
        if ($element['#type'] == 'flexbox' || $element['#type'] == 'yamlform_flexbox') {
          $this->hasFlexboxLayout = TRUE;
        }

        // Set yamlform_* prefix to #type that are using alias without yamlform_
        // namespace.
        if (!$element_info
          ->hasDefinition($element['#type']) && $element_info
          ->hasDefinition('yamlform_' . $element['#type'])) {
          $element['#type'] = 'yamlform_' . $element['#type'];
        }

        // Load the element's handler.
        $element_handler = $element_manager
          ->createInstance($element['#type']);

        // Initialize the element.
        $element_handler
          ->initialize($element);
        $element['#yamlform_multiple'] = $element_handler
          ->hasMultipleValues($element);
        $element['#yamlform_composite'] = $element_handler
          ->isComposite();
      }

      // Copy only the element properties to initialized and flattened elements.
      $this->elementsInitializedAndFlattened[$key] = YamlFormElementHelper::getProperties($element);

      // Check if element has value (aka can be exported) and add it to
      // flattened has value array.
      if ($element_handler && $element_handler
        ->isInput($element)) {
        $this->elementsFlattenedAndHasValue[$key] =& $this->elementsInitializedAndFlattened[$key];
      }
      $this
        ->initElementsRecursive($element, $key, $depth + 1);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getElement($key) {
    $elements_flattened = $this
      ->getElementsInitializedAndFlattened();
    return isset($elements_flattened[$key]) ? $elements_flattened[$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementDecoded($key) {
    $elements = $this
      ->getElementsDecodedAndFlattened();
    return isset($elements[$key]) ? $elements[$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getElementInitialized($key) {
    $elements = $this
      ->getElementsInitializedAndFlattened();
    return isset($elements[$key]) ? $elements[$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function setElementProperties($key, array $properties, $parent_key = '') {
    $elements = $this
      ->getElementsDecoded();

    // If element is was not added to elements, add it as the last element.
    if (!$this
      ->setElementPropertiesRecursive($elements, $key, $properties, $parent_key)) {
      $elements[$key] = $properties;
    }
    $this
      ->setElements($elements);
    return $this;
  }

  /**
   * Set element properties.
   *
   * @param array $elements
   *   An associative nested array of elements.
   * @param string $key
   *   The element's key.
   * @param array $properties
   *   An associative array of properties.
   * @param string $parent_key
   *   (optional) The element's parent key. Only used for new elements.
   *
   * @return bool
   *   TRUE when the element's properties has been set. FALSE when the element
   *   has not been found.
   */
  protected function setElementPropertiesRecursive(array &$elements, $key, array $properties, $parent_key = '') {
    foreach ($elements as $element_key => &$element) {
      if (Element::property($element_key) || !is_array($element)) {
        continue;
      }
      if ($element_key == $key) {
        $element = $properties + YamlFormElementHelper::removeProperties($element);
        return TRUE;
      }
      if ($element_key == $parent_key) {
        $element[$key] = $properties;
        return TRUE;
      }
      if ($this
        ->setElementPropertiesRecursive($element, $key, $properties, $parent_key)) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function deleteElement($key) {

    // Delete element from the elements render array.
    $elements = $this
      ->getElementsDecoded();
    $sub_element_keys = $this
      ->deleteElementRecursive($elements, $key);
    $this
      ->setElements($elements);

    // Delete submission element key data.
    \Drupal::database()
      ->delete('yamlform_submission_data')
      ->condition('yamlform_id', $this
      ->id())
      ->condition('name', $sub_element_keys, 'IN')
      ->execute();
  }

  /**
   * Remove an element by key from a render array.
   *
   * @param array $elements
   *   An associative nested array of elements.
   * @param string $key
   *   The element's key.
   *
   * @return bool|array
   *   An array containing the deleted element and sub element keys.
   *   FALSE is no sub elements are found.
   */
  protected function deleteElementRecursive(array &$elements, $key) {
    foreach ($elements as $element_key => &$element) {
      if (Element::property($element_key) || !is_array($element)) {
        continue;
      }
      if ($element_key == $key) {
        $sub_element_keys = [
          $element_key => $element_key,
        ];
        $this
          ->collectSubElementKeysRecursive($sub_element_keys, $element);
        unset($elements[$element_key]);
        return $sub_element_keys;
      }
      if ($sub_element_keys = $this
        ->deleteElementRecursive($element, $key)) {
        return $sub_element_keys;
      }
    }
    return FALSE;
  }

  /**
   * Collect sub element keys from a render array.
   *
   * @param array $sub_element_keys
   *   An array to be populated with sub element keys.
   * @param array $elements
   *   A render array.
   */
  protected function collectSubElementKeysRecursive(array &$sub_element_keys, array $elements) {
    foreach ($elements as $key => &$element) {
      if (Element::property($key) || !is_array($element)) {
        continue;
      }
      $sub_element_keys[$key] = $key;
      $this
        ->collectSubElementKeysRecursive($sub_element_keys, $element);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getPages() {
    if (isset($this->pages)) {
      return $this->pages;
    }
    $wizard_properties = [
      '#title' => '#title',
      '#prev_button_label' => '#prev_button_label',
      '#next_button_label' => '#next_button_label',
    ];
    $elements = $this
      ->getElementsInitialized();

    // Add form page containers.
    $this->pages = [];
    if (is_array($elements)) {
      foreach ($elements as $key => $element) {
        if (isset($element['#type']) && $element['#type'] == 'yamlform_wizard_page') {
          $this->pages[$key] = array_intersect_key($element, $wizard_properties);
        }
      }
    }

    // Add preview page.
    $settings = $this
      ->getSettings();
    if ($settings['preview'] != DRUPAL_DISABLED) {

      // If there is no start page, we must define one.
      if (empty($this->pages)) {
        $this->pages['start'] = [
          '#title' => $this
            ->getSetting('wizard_start_label') ?: \Drupal::config('yamlform.settings')
            ->get('settings.default_wizard_start_label'),
        ];
      }
      $this->pages['preview'] = [
        '#title' => $this
          ->t('Preview'),
      ];
    }

    // Only add complete page, if there are some pages.
    if ($this->pages && $this
      ->getSetting('wizard_complete')) {
      $this->pages['complete'] = [
        '#title' => $this
          ->getSetting('wizard_complete_label') ?: \Drupal::config('yamlform.settings')
          ->get('settings.default_wizard_complete_label'),
      ];
    }
    return $this->pages;
  }

  /**
   * {@inheritdoc}
   */
  public function getPage($key) {
    $pages = $this
      ->getPages();
    return isset($pages[$key]) ? $pages[$key] : NULL;
  }

  /**
   * {@inheritdoc}
   */
  public static function preCreate(EntityStorageInterface $storage, array &$values) {
    $values += [
      'uid' => \Drupal::currentUser()
        ->id(),
      'settings' => self::getDefaultSettings(),
      'access' => self::getDefaultAccessRules(),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public static function postLoad(EntityStorageInterface $storage, array &$entities) {
    foreach ($entities as $entity) {
      $entity->elementsOriginal = $entity->elements;
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {

    /** @var \Drupal\yamlform\YamlFormInterface[] $entities */
    parent::preDelete($storage, $entities);

    // Delete all paths and states associated with this form.
    foreach ($entities as $entity) {

      // Delete all paths.
      $entity
        ->deletePaths();

      // Delete the state.
      \Drupal::state()
        ->delete('yamlform.yamlform.' . $entity
        ->id());
    }

    // Delete all submission associated with this form.
    $submission_ids = \Drupal::entityQuery('yamlform_submission')
      ->condition('yamlform_id', array_keys($entities), 'IN')
      ->sort('sid')
      ->execute();
    $submission_storage = \Drupal::entityTypeManager()
      ->getStorage('yamlform_submission');
    $submissions = $submission_storage
      ->loadMultiple($submission_ids);
    $submission_storage
      ->delete($submissions);
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheTags() {
    $cache_tags = parent::getCacheTags();

    // Add form to cache tags which are used by the YamlFormSubmissionForm.
    $cache_tags[] = 'yamlform:' . $this
      ->id();
    return $cache_tags;
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {

    // Always unpublish templates.
    if ($this
      ->isTemplate()) {
      $this
        ->setStatus(FALSE);
    }

    // Serialize elements array to YAML.
    if (is_array($this->elements)) {
      $this->elements = Yaml::encode($this->elements);
    }
    parent::preSave($storage);
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    // Update paths.
    $this
      ->updatePaths();

    // Reset elements.
    $this
      ->resetElements();
  }

  /**
   * {@inheritdoc}
   */
  public function updatePaths() {

    // Path module must be enable for URL aliases to be updated.
    if (!\Drupal::moduleHandler()
      ->moduleExists('path')) {
      return;
    }

    // Update submit path.
    $submit_path = $this->settings['page_submit_path'] ?: trim(\Drupal::config('yamlform.settings')
      ->get('settings.default_page_base_path'), '/') . '/' . str_replace('_', '-', $this
      ->id());
    $submit_source = '/yamlform/' . $this
      ->id();
    $submit_alias = '/' . trim($submit_path, '/');
    $this
      ->updatePath($submit_source, $submit_alias, $this->langcode);
    $this
      ->updatePath($submit_source, $submit_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);

    // Update confirm path.
    $confirm_path = $this->settings['page_confirm_path'] ?: $submit_path . '/confirmation';
    $confirm_source = '/yamlform/' . $this
      ->id() . '/confirmation';
    $confirm_alias = '/' . trim($confirm_path, '/');
    $this
      ->updatePath($confirm_source, $confirm_alias, $this->langcode);
    $this
      ->updatePath($confirm_source, $confirm_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);

    // Update submissions path.
    $submissions_path = $submit_path . '/submissions';
    $submissions_source = '/yamlform/' . $this
      ->id() . '/submissions';
    $submissions_alias = '/' . trim($submissions_path, '/');
    $this
      ->updatePath($submissions_source, $submissions_alias, $this->langcode);
    $this
      ->updatePath($submissions_source, $submissions_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);
  }

  /**
   * {@inheritdoc}
   */
  public function deletePaths() {

    /** @var \Drupal\Core\Path\AliasStorageInterface $path_alias_storage */
    $path_alias_storage = \Drupal::service('path.alias_storage');
    $path_alias_storage
      ->delete([
      'source' => '/yamlform/' . $this
        ->id(),
    ]);
    $path_alias_storage
      ->delete([
      'source' => '/yamlform/' . $this
        ->id() . '/confirmation',
    ]);
  }

  /**
   * Saves a path alias to the database.
   *
   * @param string $source
   *   The internal system path.
   * @param string $alias
   *   The URL alias.
   * @param string $langcode
   *   (optional) The language code of the alias.
   */
  protected function updatePath($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED) {

    /** @var \Drupal\Core\Path\AliasStorageInterface $path_alias_storage */
    $path_alias_storage = \Drupal::service('path.alias_storage');
    $path = $path_alias_storage
      ->load([
      'source' => $source,
      'langcode' => $langcode,
    ]);

    // Check if the path alias is already setup.
    if ($path && $path['alias'] == $alias) {
      return;
    }
    $path_alias_storage
      ->save($source, $alias, $langcode, $path['pid']);
  }

  /**
   * {@inheritdoc}
   */
  public function deleteYamlFormHandler(YamlFormHandlerInterface $handler) {
    $this
      ->getHandlers()
      ->removeInstanceId($handler
      ->getHandlerId());
    $this
      ->save();
    return $this;
  }

  /**
   * Returns the form handler plugin manager.
   *
   * @return \Drupal\Component\Plugin\PluginManagerInterface
   *   The form handler plugin manager.
   */
  protected function getYamlFormHandlerPluginManager() {
    return \Drupal::service('plugin.manager.yamlform.handler');
  }

  /**
   * {@inheritdoc}
   */
  public function getHandler($handler) {
    return $this
      ->getHandlers()
      ->get($handler);
  }

  /**
   * {@inheritdoc}
   */
  public function getHandlers($plugin_id = NULL, $status = NULL, $results = NULL) {
    if (!$this->handlersCollection) {
      $this->handlersCollection = new YamlFormHandlerPluginCollection($this
        ->getYamlFormHandlerPluginManager(), $this->handlers);

      /** @var \Drupal\yamlform\YamlFormHandlerBase $handler */
      foreach ($this->handlersCollection as $handler) {

        // Initialize the handler and pass in the form.
        $handler
          ->init($this);
      }
      $this->handlersCollection
        ->sort();
    }

    /** @var \Drupal\yamlform\YamlFormHandlerPluginCollection $handlers */
    $handlers = $this->handlersCollection;

    // Clone the handlers if they are being filtered.
    if (isset($plugin_id) || isset($status) || isset($results)) {

      /** @var \Drupal\yamlform\YamlFormHandlerPluginCollection $handlers */
      $handlers = clone $this->handlersCollection;
    }

    // Filter the handlers by plugin id.
    // This is used to limit track and enforce a handlers cardinality.
    if (isset($plugin_id)) {
      foreach ($handlers as $instance_id => $handler) {
        if ($handler
          ->getPluginId() != $plugin_id) {
          $handlers
            ->removeInstanceId($instance_id);
        }
      }
    }

    // Filter the handlers by status.
    // This is used to limit track and enforce a handlers cardinality.
    if (isset($status)) {
      foreach ($handlers as $instance_id => $handler) {
        if ($handler
          ->getStatus() != $status) {
          $handlers
            ->removeInstanceId($instance_id);
        }
      }
    }

    // Filter the handlers by results.
    // This is used to track is results are processed or ignored.
    if (isset($results)) {
      foreach ($handlers as $instance_id => $handler) {
        $plugin_definition = $handler
          ->getPluginDefinition();
        if ($plugin_definition['results'] != $results) {
          $handlers
            ->removeInstanceId($instance_id);
        }
      }
    }
    return $handlers;
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginCollections() {
    return [
      'handlers' => $this
        ->getHandlers(),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function addYamlFormHandler(array $configuration) {
    $this
      ->getHandlers()
      ->addInstanceId($configuration['handler_id'], $configuration);
    return $configuration['handler_id'];
  }

  /**
   * {@inheritdoc}
   */
  public function invokeHandlers($method, &$data, &$context1 = NULL, &$context2 = NULL) {
    $handlers = $this
      ->getHandlers();
    foreach ($handlers as $handler) {
      if ($handler
        ->isEnabled()) {
        $handler
          ->{$method}($data, $context1, $context2);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function invokeElements($method, &$data, &$context1 = NULL, &$context2 = NULL) {

    /** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
    $element_manager = \Drupal::service('plugin.manager.yamlform.element');
    $elements = $this
      ->getElementsInitializedAndFlattened();
    foreach ($elements as $element) {
      $element_manager
        ->invokeMethod($method, $element, $data, $context1, $context2);
    }
  }

  /**
   * {@inheritdoc}
   *
   * Overriding so that URLs pointing to form default to 'canonical'
   * submission form and not the back-end 'edit-form'.
   */
  public function url($rel = 'canonical', $options = []) {

    // Do not remove this override: the default value of $rel is different.
    return parent::url($rel, $options);
  }

  /**
   * {@inheritdoc}
   *
   * Overriding so that URLs pointing to form default to 'canonical'
   * submission form and not the back-end 'edit-form'.
   */
  public function toUrl($rel = 'canonical', array $options = []) {
    return parent::toUrl($rel, $options);
  }

  /**
   * {@inheritdoc}
   *
   * Overriding so that URLs pointing to form default to 'canonical'
   * submission form and not the back-end 'edit-form'.
   */
  public function urlInfo($rel = 'canonical', array $options = []) {
    return parent::urlInfo($rel, $options);
  }

  /**
   * {@inheritdoc}
   *
   * Overriding so that links to form default to 'canonical' submission
   * form and not the back-end 'edit-form'.
   */
  public function toLink($text = NULL, $rel = 'canonical', array $options = []) {
    return parent::toLink($text, $rel, $options);
  }

  /**
   * {@inheritdoc}
   *
   * Overriding so that links to form default to 'canonical' submission
   * form and not the back-end 'edit-form'.
   */
  public function link($text = NULL, $rel = 'canonical', array $options = []) {
    return parent::link($text, $rel, $options);
  }

  /**
   * {@inheritdoc}
   */
  public function isDefaultRevision() {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function getState($key, $default = NULL) {
    $namespace = 'yamlform.yamlform.' . $this
      ->id();
    $values = \Drupal::state()
      ->get($namespace, []);
    return isset($values[$key]) ? $values[$key] : $default;
  }

  /**
   * {@inheritdoc}
   */
  public function setState($key, $value) {
    $namespace = 'yamlform.yamlform.' . $this
      ->id();
    $values = \Drupal::state()
      ->get($namespace, []);
    $values[$key] = $value;
    \Drupal::state()
      ->set($namespace, $values);
  }

  /**
   * {@inheritdoc}
   */
  public function deleteState($key) {
    $namespace = 'yamlform.yamlform.' . $this
      ->id();
    $values = \Drupal::state()
      ->get($namespace, []);
    unset($values[$key]);
    \Drupal::state()
      ->set($namespace, $values);
  }

  /**
   * {@inheritdoc}
   */
  public function hasState($key) {
    $namespace = 'yamlform.yamlform.' . $this
      ->id();
    $values = \Drupal::state()
      ->get($namespace, []);
    return isset($values[$key]) ? TRUE : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function onDependencyRemoval(array $dependencies) {
    $changed = parent::onDependencyRemoval($dependencies);
    $handlers = $this
      ->getHandlers();
    if (empty($handlers)) {
      return $changed;
    }
    foreach ($handlers as $handler) {
      $plugin_definition = $handler
        ->getPluginDefinition();
      $provider = $plugin_definition['provider'];
      if (in_array($provider, $dependencies['module'])) {
        $this
          ->deleteYamlFormHandler($handler);
        $changed = TRUE;
      }
    }
    return $changed;
  }

  /**
   * Define empty array iterator.
   *
   * See: Issue #2759267: Undefined method YamlForm::getIterator().
   */
  public function getIterator() {
    return new \ArrayIterator([]);
  }

}

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::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$_core protected property Information maintained by Drupal core about configuration.
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 13
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::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::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
ConfigEntityBundleBase::deleteDisplays protected function Deletes display if a bundle is deleted.
ConfigEntityBundleBase::loadDisplays protected function Returns view or form displays for this bundle.
ConfigEntityBundleBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete 2
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 Aliased as: traitSleep 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. 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::entityManager Deprecated protected function Gets the entity manager.
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::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::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
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. 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.
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
YamlForm::$access protected property The form access controls.
YamlForm::$css protected property The CSS stylesheet.
YamlForm::$description protected property The form description.
YamlForm::$elements protected property The form elements.
YamlForm::$elementsDecoded protected property The form elements decoded.
YamlForm::$elementsDecodedAndFlattened protected property The form elements decoded and flattened.
YamlForm::$elementsFlattenedAndHasValue protected property The form elements flattened and has value.
YamlForm::$elementsInitialized protected property The form elements initializes (and decoded).
YamlForm::$elementsInitializedAndFlattened protected property The form elements initialized and flattened.
YamlForm::$elementsOriginal protected property The form elements original.
YamlForm::$elementsTranslations protected property The form elements translations.
YamlForm::$handlers protected property The array of form handlers for this form.
YamlForm::$handlersCollection protected property Holds the collection of form handlers that are used by this form.
YamlForm::$hasFlexboxLayout protected property Track if the form is using a flexbox layout.
YamlForm::$hasManagedFile protected property Track if the form has a managed file (upload) element.
YamlForm::$hasTranslations protected property Track if the form has translations.
YamlForm::$id protected property The form ID.
YamlForm::$javascript protected property The JavaScript.
YamlForm::$pages protected property The form pages.
YamlForm::$settings protected property The form settings.
YamlForm::$status protected property The form status. Overrides ConfigEntityBase::$status
YamlForm::$template protected property The form template indicator.
YamlForm::$title protected property The form title.
YamlForm::$uid protected property The owner's uid.
YamlForm::$uuid protected property The form UUID. Overrides ConfigEntityBase::$uuid
YamlForm::addYamlFormHandler public function Saves a form handler for this form. Overrides YamlFormInterface::addYamlFormHandler
YamlForm::checkAccessRule protected function Checks an access rule against a user account's roles and id.
YamlForm::checkAccessRules public function Checks form access to an operation on a form's submission. Overrides YamlFormInterface::checkAccessRules
YamlForm::collectSubElementKeysRecursive protected function Collect sub element keys from a render array.
YamlForm::deleteElement public function Remove an element. Overrides YamlFormInterface::deleteElement
YamlForm::deleteElementRecursive protected function Remove an element by key from a render array.
YamlForm::deletePaths public function Update submit and confirm paths associated with this form. Overrides YamlFormInterface::deletePaths
YamlForm::deleteState public function Deletes an item from the form's state. Overrides YamlFormInterface::deleteState
YamlForm::deleteYamlFormHandler public function Deletes a form handler from this style. Overrides YamlFormInterface::deleteYamlFormHandler
YamlForm::getAccessRules public function Returns the form access controls. Overrides YamlFormInterface::getAccessRules
YamlForm::getCacheTags public function The cache tags associated with this object. Overrides EntityBase::getCacheTags
YamlForm::getCss public function Returns the form's CSS. Overrides YamlFormInterface::getCss
YamlForm::getDefaultAccessRules public static function Returns the form default access controls. Overrides YamlFormInterface::getDefaultAccessRules
YamlForm::getDefaultSettings public static function Returns the form default settings. Overrides YamlFormInterface::getDefaultSettings
YamlForm::getDescription public function Returns the form's description. Overrides YamlFormInterface::getDescription
YamlForm::getElement public function Get a form's initialized element. Overrides YamlFormInterface::getElement
YamlForm::getElementDecoded public function Get a form's raw (uninitialized) element. Overrides YamlFormInterface::getElementDecoded
YamlForm::getElementInitialized public function
YamlForm::getElementsDecoded public function Get form elements decoded as an associative array. Overrides YamlFormInterface::getElementsDecoded
YamlForm::getElementsDecodedAndFlattened public function Get form raw elements decoded and flattened into an associative array. Overrides YamlFormInterface::getElementsDecodedAndFlattened
YamlForm::getElementsFlattenedAndHasValue public function Get form flattened list of elements. Overrides YamlFormInterface::getElementsFlattenedAndHasValue
YamlForm::getElementsInitialized public function Get form elements initialized as an associative array. Overrides YamlFormInterface::getElementsInitialized
YamlForm::getElementsInitializedAndFlattened public function Get form elements initialized and flattened into an associative array. Overrides YamlFormInterface::getElementsInitializedAndFlattened
YamlForm::getElementsOriginalRaw public function Get original elements (YAML) value. Overrides YamlFormInterface::getElementsOriginalRaw
YamlForm::getElementsRaw public function Get elements (YAML) value. Overrides YamlFormInterface::getElementsRaw
YamlForm::getElementsSelectorOptions public function Get form elements selectors as options. Overrides YamlFormInterface::getElementsSelectorOptions
YamlForm::getHandler public function Returns a specific form handler. Overrides YamlFormInterface::getHandler
YamlForm::getHandlers public function Returns the form handlers for this form. Overrides YamlFormInterface::getHandlers
YamlForm::getIterator public function Define empty array iterator.
YamlForm::getJavaScript public function Returns the form's JavaScript. Overrides YamlFormInterface::getJavaScript
YamlForm::getOwner public function Returns the entity owner's user entity. Overrides EntityOwnerInterface::getOwner
YamlForm::getOwnerId public function Returns the entity owner's user ID. Overrides EntityOwnerInterface::getOwnerId
YamlForm::getPage public function Get form wizard page. Overrides YamlFormInterface::getPage
YamlForm::getPages public function Get form wizard pages. Overrides YamlFormInterface::getPages
YamlForm::getPluginCollections public function Gets the plugin collections used by this object. Overrides ObjectWithPluginCollectionInterface::getPluginCollections
YamlForm::getSetting public function Returns the form settings for a given key. Overrides YamlFormInterface::getSetting
YamlForm::getSettings public function Returns the form settings. Overrides YamlFormInterface::getSettings
YamlForm::getState public function Returns the stored value for a given key in the form's state. Overrides YamlFormInterface::getState
YamlForm::getSubmissionForm public function Get form submission form. Overrides YamlFormInterface::getSubmissionForm
YamlForm::getYamlFormHandlerPluginManager protected function Returns the form handler plugin manager.
YamlForm::hasFlexboxLayout public function Determine if the form is using a Flexbox layout. Overrides YamlFormInterface::hasFlexboxLayout
YamlForm::hasManagedFile public function Determine if the form's elements include a managed_file upload element. Overrides YamlFormInterface::hasManagedFile
YamlForm::hasPage public function Determine if the form has page or is attached to other entities. Overrides YamlFormInterface::hasPage
YamlForm::hasState public function Determine if the stored value for a given key exists in the form's state. Overrides YamlFormInterface::hasState
YamlForm::hasSubmissions public function Checks if a form has submissions. Overrides YamlFormInterface::hasSubmissions
YamlForm::hasTranslations public function Determine if the current form is translated. Overrides YamlFormInterface::hasTranslations
YamlForm::initElements protected function Initialize parse form elements.
YamlForm::initElementsRecursive protected function Initialize form elements into a flatten array.
YamlForm::invokeElements public function Invoke elements method. Overrides YamlFormInterface::invokeElements
YamlForm::invokeHandlers public function Invoke a handlers method. Overrides YamlFormInterface::invokeHandlers
YamlForm::isClosed public function Returns the form closed status indicator. Overrides YamlFormInterface::isClosed
YamlForm::isConfidential public function Returns the form confidential indicator. Overrides YamlFormInterface::isConfidential
YamlForm::isDefaultRevision public function Required to allow form which are config entities to have an EntityViewBuilder. Overrides YamlFormInterface::isDefaultRevision
YamlForm::isOpen public function Returns the form opened status indicator. Overrides YamlFormInterface::isOpen
YamlForm::isTemplate public function Returns the form template indicator. Overrides YamlFormInterface::isTemplate
YamlForm::link public function Overriding so that links to form default to 'canonical' submission form and not the back-end 'edit-form'. Overrides ConfigEntityBase::link
YamlForm::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityBase::onDependencyRemoval
YamlForm::postLoad public static function Acts on loaded entities. Overrides EntityBase::postLoad
YamlForm::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides ConfigEntityBundleBase::postSave
YamlForm::preCreate public static function Changes the values of an entity before it is created. Overrides EntityBase::preCreate
YamlForm::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides ConfigEntityBase::preDelete
YamlForm::preSave public function Acts on an entity before the presave hook is invoked. Overrides ConfigEntityBundleBase::preSave
YamlForm::resetElements protected function Reset parsed and cached form elements.
YamlForm::setAccessRules public function Sets the form access. Overrides YamlFormInterface::setAccessRules
YamlForm::setCss public function Sets the form's CSS. Overrides YamlFormInterface::setCss
YamlForm::setDescription public function Sets a form's description. Overrides YamlFormInterface::setDescription
YamlForm::setElementProperties public function Set element properties. Overrides YamlFormInterface::setElementProperties
YamlForm::setElementPropertiesRecursive protected function Set element properties.
YamlForm::setElements public function Sets elements (YAML) value. Overrides YamlFormInterface::setElements
YamlForm::setJavaScript public function Sets the form's JavaScript. Overrides YamlFormInterface::setJavaScript
YamlForm::setOwner public function Sets the entity owner's user entity. Overrides EntityOwnerInterface::setOwner
YamlForm::setOwnerId public function Sets the entity owner's user ID. Overrides EntityOwnerInterface::setOwnerId
YamlForm::setSetting public function Saves a form setting for a given key. Overrides YamlFormInterface::setSetting
YamlForm::setSettings public function Sets the form settings. Overrides YamlFormInterface::setSettings
YamlForm::setState public function Saves a value for a given key in the form's state. Overrides YamlFormInterface::setState
YamlForm::toLink public function Overriding so that links to form default to 'canonical' submission form and not the back-end 'edit-form'. Overrides EntityBase::toLink
YamlForm::toUrl public function Overriding so that URLs pointing to form default to 'canonical' submission form and not the back-end 'edit-form'. Overrides ConfigEntityBase::toUrl
YamlForm::updatePath protected function Saves a path alias to the database.
YamlForm::updatePaths public function Update submit and confirm paths (ie URL aliases) associated with this form. Overrides YamlFormInterface::updatePaths
YamlForm::url public function Overriding so that URLs pointing to form default to 'canonical' submission form and not the back-end 'edit-form'. Overrides ConfigEntityBase::url
YamlForm::urlInfo public function Overriding so that URLs pointing to form default to 'canonical' submission form and not the back-end 'edit-form'. Overrides ConfigEntityBase::urlInfo