"Components" seem a misleading keyword in the code

Created on 15 August 2022, over 2 years ago
Updated 24 August 2023, about 1 year ago

Throughout the code various function are using "element" but also "component" keyword such as getComponents(). As the term are so close, it make the code a bit hard to read.

I don't really understand what represent a "component". My understanding is that webform have only element and submissions.

It is particular strange when you have a function like that:

  /**
   * Get Components.
   *
   * @return array
   *   Components renderable.
   */
  public function getComponents() {

    foreach ($this->analysis->getElements() as $element_name => $element) {
      $options[$element_name] = isset($element['#title']) ? $element['#title'] : $element_name;
    }

    return [
      '#type'          => 'checkboxes',
      '#options'       => $options,
      '#default_value' => (array) $this->analysis->getComponents(),
    ];
  }

This function actually getElements and construct a renderable array to construct the form checkbox. For example, buildFormWebformElementsCheckbox() seem a better name to me.

Similarly, in the WebformAnalysis class the function getComponentValuesCount($components) could be getElementValuesCount(array $elementsName) .

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland gagarine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024