You are here

public function TourTipController::edit in Tour UI 8

Provides an edit form for tip to be updated against a tour entity.

Parameters

\Drupal\tour\Entity\Tour $tour: The tour in which the tip is being edited against.

string $tip: The identifier of tip that will be edited against the tour.

Return value

array A renderable form array.

Throws

\Drupal\Core\Form\EnforcedResponseException

\Drupal\Core\Form\FormAjaxException

File

src/Controller/TourTipController.php, line 124

Class

TourTipController
Handles page returns for tour tip.

Namespace

Drupal\tour_ui\Controller

Code

public function edit(Tour $tour, $tip = '') {

  // We need a tip to build this form.
  if (!$tip && !$tour) {
    throw new NotFoundHttpException();
  }
  try {
    $the_tip = $tour
      ->getTip($tip);
  } catch (PluginNotFoundException $e) {
    throw new NotFoundHttpException();
  }

  // Attach the tour and tip.
  $form_state = new FormState();
  $form_state
    ->setFormState([
    '#tour' => $tour,
    '#tip' => $the_tip,
  ]);
  return $this->formBuilder
    ->buildForm('\\Drupal\\tour_ui\\Form\\TourTipForm', $form_state);
}