Commit a2012650 authored by Rob Phillips's avatar Rob Phillips
Browse files

Issue #3323658 by robphillips: Improve code quality and documentation.

parent acf26d5b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

/**
 * @file
 * Install, update, and uninstall functions for the Entity Form Steps module.
 * Install, update, and uninstall functions.
 */

/**
+0 −20
Original line number Diff line number Diff line
@@ -7,8 +7,6 @@

use Drupal\Core\Entity\ContentEntityFormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\entity_form_steps\Form\EntityFormSteps;

/**
@@ -63,21 +61,3 @@ function _entity_form_steps_form_entity_display_form_validate($form, FormStateIn
  }
  $formState->setValue('fields', $fields);
}

/**
 * Implements hook_help().
 */
function entity_form_steps_help($route_name, RouteMatchInterface $route_match): string {
  $build = [];
  if ($route_name === 'help.page.entity_form_steps') {
    $build[] = [
      '#markup' => '<h2>' . t('Documentation') . '</h2>',
    ];
    $build[] = [
      '#type' => 'link',
      '#title' => 'https://git.drupalcode.org/project/entity_form_steps/-/blob/1.x/README.md',
      '#url' => Url::fromUri('https://git.drupalcode.org/project/entity_form_steps/-/blob/1.x/README.md'),
    ];
  }
  return \Drupal::service('renderer')->render($build);
}
+2 −6
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@ class EntityFormSteps {
   *   Returns an array of ordered steps.
   */
  public static function getSteps(FormStateInterface $formState): array {
    /** @var \Drupal\Core\Entity\ContentEntityForm $formObject */
    $formObject = $formState->getFormObject();
    /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $formDisplay */
    $formDisplay = $formState->getStorage()['form_display'];

@@ -33,7 +31,7 @@ class EntityFormSteps {
    uasort($steps, [SortArray::class, 'sortByWeightElement']);

    if ($steps) {
      $entity = $formObject->getEntity();
      $entity = $formState->getFormObject()->getEntity();
      // Invoke hook_entity_form_steps_alter().
      \Drupal::moduleHandler()->invokeAll(
        "entity_form_steps_alter",
@@ -223,9 +221,7 @@ class EntityFormSteps {
   *   Returns a URL.
   */
  public static function getCancelUrl(array $state, FormStateInterface $formState): Url {
    /** @var \Drupal\Core\Entity\ContentEntityForm $formObject */
    $formObject = $formState->getFormObject();
    $entity = $formObject->getEntity();
    $entity = $formState->getFormObject()->getEntity();
    $step = $state['steps'][$state['current_step']];

    // Redirect to specified route if configured.