You are here

class Overview in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/forum/src/Form/Overview.php \Drupal\forum\Form\Overview

Hierarchy

Expanded class hierarchy of Overview

2 string references to 'Overview'
DbUpdateController::updateTasksList in core/modules/system/src/Controller/DbUpdateController.php
Provides the update task list render array.
forum.routing.yml in core/modules/forum/forum.routing.yml
core/modules/forum/forum.routing.yml

File

core/modules/forum/src/Form/Overview.php, line 21
Contains \Drupal\forum\Form\Overview.

Namespace

Drupal\forum\Form
View source
class Overview extends OverviewTerms {

  /**
   * Entity manager Service Object.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * Constructs a \Drupal\forum\Form\OverviewForm object.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler service.
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
   *   The entity manager service.
   */
  public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) {
    parent::__construct($module_handler, $entity_manager);
    $this->entityManager = $entity_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'forum_overview';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $forum_config = $this
      ->config('forum.settings');
    $vid = $forum_config
      ->get('vocabulary');
    $vocabulary = $this->entityManager
      ->getStorage('taxonomy_vocabulary')
      ->load($vid);
    if (!$vocabulary) {
      throw new NotFoundHttpException();
    }

    // Build base taxonomy term overview.
    $form = parent::buildForm($form, $form_state, $vocabulary);
    foreach (Element::children($form['terms']) as $key) {
      if (isset($form['terms'][$key]['#term'])) {
        $term = $form['terms'][$key]['#term'];
        $form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', [
          'taxonomy_term' => $term
            ->id(),
        ]);
        unset($form['terms'][$key]['operations']['#links']['delete']);
        $route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']
          ->getRouteParameters();
        if (!empty($term->forum_container->value)) {
          $form['terms'][$key]['operations']['#links']['edit']['title'] = $this
            ->t('edit container');
          $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters);
        }
        else {
          $form['terms'][$key]['operations']['#links']['edit']['title'] = $this
            ->t('edit forum');
          $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters);
        }

        // We don't want the redirect from the link so we can redirect the
        // delete action.
        unset($form['terms'][$key]['operations']['#links']['edit']['query']['destination']);
      }
    }

    // Remove the alphabetical reset.
    unset($form['actions']['reset_alphabetical']);

    // Use the existing taxonomy overview submit handler.
    $form['terms']['#empty'] = $this
      ->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', array(
      ':container' => $this
        ->url('forum.add_container'),
      ':forum' => $this
        ->url('forum.add_forum'),
    ));
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 3
FormBase::$loggerFactory protected property The logger factory.
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 3
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 64
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator protected function Returns the link generator.
LinkGeneratorTrait::l protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator public function Sets the link generator service.
Overview::$entityManager protected property Entity manager Service Object.
Overview::buildForm public function Form constructor. Overrides OverviewTerms::buildForm
Overview::getFormId public function Returns a unique string identifying the form. Overrides OverviewTerms::getFormId
Overview::__construct public function Constructs a \Drupal\forum\Form\OverviewForm object. Overrides OverviewTerms::__construct
OverviewTerms::$moduleHandler protected property The module handler service.
OverviewTerms::$storageController protected property The term storage controller.
OverviewTerms::create public static function Instantiates a new instance of this class. Overrides FormBase::create
OverviewTerms::submitForm public function Form submission handler. Overrides FormInterface::submitForm
OverviewTerms::submitReset public function Redirects to confirmation form for the reset action.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service.
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service.
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.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator protected function Returns the URL generator service.
UrlGeneratorTrait::redirect protected function Returns a redirect response object for the specified route.
UrlGeneratorTrait::setUrlGenerator public function Sets the URL generator service.
UrlGeneratorTrait::url protected function Generates a URL or path for a specific route based on the given parameters.