Same name and namespace in other branches
- 8.9.x core/modules/forum/src/Form/Overview.php \Drupal\forum\Form\Overview
- 9 core/modules/forum/src/Form/Overview.php \Drupal\forum\Form\Overview
Provides forum overview form for the forum vocabulary.
@internal
Hierarchy
- class \Drupal\forum\Form\Overview extends \Drupal\taxonomy\Form\OverviewTerms
Expanded class hierarchy of Overview
2 string references to 'Overview'
- content_moderation.links.task.yml in core/
modules/ content_moderation/ content_moderation.links.task.yml - core/modules/content_moderation/content_moderation.links.task.yml
- 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 17
Namespace
Drupal\forum\FormView source
class Overview extends OverviewTerms {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'forum_overview';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
$forum_config = $this
->config('forum.settings');
$vid = $forum_config
->get('vocabulary');
$vocabulary = $this->entityTypeManager
->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'])) {
/** @var \Drupal\taxonomy\TermInterface $term */
$term = $form['terms'][$key]['#term'];
$form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', [
'taxonomy_term' => $term
->id(),
]);
if (!empty($term->forum_container->value)) {
$title = $this
->t('edit container');
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', [
'taxonomy_term' => $term
->id(),
]);
}
else {
$title = $this
->t('edit forum');
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_form', [
'taxonomy_term' => $term
->id(),
]);
}
// Re-create the operations column and add only the edit link.
$form['terms'][$key]['operations'] = [
'#type' => 'operations',
'#links' => [
'edit' => [
'title' => $title,
'url' => $url,
],
],
];
}
}
// 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>.', [
':container' => Url::fromRoute('forum.add_container')
->toString(),
':forum' => Url::fromRoute('forum.add_forum')
->toString(),
]);
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Overview:: |
public | function | ||
Overview:: |
public | function |