lgmsDashboardController
extends ControllerBase
in package
Manages the display and functionality of the LGMS Dashboard.
This controller provides methods for rendering the dashboard overview, adding new guides, and reusing existing guides through a custom form. It utilizes Drupal's View system to list items on the dashboard and leverages Drupal's Form API for the creation and management of content.
Table of Contents
Methods
- new() : array<string|int, mixed>
- Provides a form for creating a new guide.
- overview() : array<string|int, mixed>
- Renders the LGMS Dashboard overview page.
- reuse() : array<string|int, mixed>
- Renders the form for reusing existing guides.
Methods
new()
Provides a form for creating a new guide.
public
new() : array<string|int, mixed>
This method utilizes Drupal's entity form system to generate a form for creating a new guide of the 'guide' content type. It returns the form render array to Drupal for display.
Return values
array<string|int, mixed> —The form render array for creating a new guide.
overview()
Renders the LGMS Dashboard overview page.
public
overview() : array<string|int, mixed>
This method prepares and returns a render array for the dashboard page, which includes a list of guides displayed through a View. If no guides are available, a message is displayed. It also includes a search bar and contextual links for users with appropriate permissions.
Return values
array<string|int, mixed> —A Drupal render array containing the dashboard content, including the guides list view, a search bar, and potentially a message indicating no guides are owned by the user.
reuse()
Renders the form for reusing existing guides.
public
reuse() : array<string|int, mixed>
Fetches and returns the custom form defined by 'Drupal\lgmsmodule\Form\ReuseGuideForm' allowing users to reuse existing guides. This demonstrates an example of integrating custom forms within controller methods.
Return values
array<string|int, mixed> —The form render array for the guide reuse form.