<?php

namespace Drupal\azure_ad\Controller;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;

/**
 * Azure AD Controller.
 */
class MoAzureController extends ControllerBase {

  /**
   * Constructor for MoAzureController.
   */
  public function __construct(ConfigFactoryInterface $config_factory, MessengerInterface $messenger, FormBuilderInterface $form_builder) {
    $this->configFactory = $config_factory;
    $this->messenger = $messenger;
    $this->formBuilder = $form_builder;
  }

  /**
   * Configure the app.
   */
  public function configureApp($app) {
    $this->configFactory->getEditable('azure_ad.settings')->set('azure_ad_provisioning_step', 'step3')->save();
    $path = Url::fromRoute('azure_ad.overview')->toString();
    $response = new RedirectResponse($path);
    $response->send();
    return $response;
  }

}
