farm_settings.module in farmOS 2.x
Contains farm_settings.module.
File
modules/core/settings/farm_settings.moduleView source
<?php
/**
* @file
* Contains farm_settings.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_help().
*/
function farm_settings_help($route_name, RouteMatchInterface $route_match) {
$output = '';
// Modules form.
if ($route_name == 'farm_settings.modules_form') {
$output .= '<p>' . t('Select the core and community farmOS modules that you would like to be installed.') . '</p>';
}
return $output;
}
/**
* Implements hook_toolbar().
*/
function farm_settings_toolbar() {
$user = \Drupal::currentUser();
$items = [];
$items['farm_settings'] = [
'#cache' => [
'contexts' => [
'user.permissions',
],
],
];
// Add settings to the toolbar if the user has permission.
if ($user
->hasPermission('administer farm settings')) {
$items['farm_settings'] += [
'#type' => 'toolbar_item',
'tab' => [
'#type' => 'link',
'#title' => t('Settings'),
'#url' => Url::fromRoute('farm_settings.settings_page'),
'#attributes' => [
'title' => t('Settings'),
'class' => [
'toolbar-icon',
'toolbar-icon-farm-settings',
],
],
'#attached' => [
'library' => [
'farm_settings/toolbar',
],
],
],
'#weight' => -5,
];
}
return $items;
}
Functions
Name | Description |
---|---|
farm_settings_help | Implements hook_help(). |
farm_settings_toolbar | Implements hook_toolbar(). |