clean install

This commit is contained in:
matze committed 2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 files changed
+3555714

No files matched your search

@@ -0,0 +1,5 @@
name: farmOS Setup
description: Provides setup pages for farmOS.
type: module
package: farmOS
core_version_requirement: ^10
@@ -0,0 +1,4 @@
farm.setup:
title: Setup
parent: system.admin
route_name: farm.setup
@@ -0,0 +1,3 @@
farm_setup:
config_permissions:
- access farm setup
@@ -0,0 +1,2 @@
access farm setup:
title: 'Access farmOS setup'
@@ -0,0 +1,7 @@
farm.setup:
path: /setup
defaults:
_controller: \Drupal\farm_setup\Controller\SetupController::index
_title: Setup
requirements:
_permission: access farm setup
@@ -0,0 +1,95 @@
<?php
namespace Drupal\farm_setup\Controller;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Setup controller.
*/
class SetupController extends ControllerBase {
use StringTranslationTrait;
/**
* The menu link tree service.
*
* @var \Drupal\Core\Menu\MenuLinkTreeInterface
*/
protected $menuLinkTree;
/**
* Constructs a new SetupController.
*
* @param \Drupal\Core\Menu\MenuLinkTreeInterface $menu_link_tree
* The menu link tree service.
*/
public function __construct(MenuLinkTreeInterface $menu_link_tree) {
$this->menuLinkTree = $menu_link_tree;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('menu.link_tree')
);
}
/**
* The index of reports.
*
* @return array
* Returns a render array.
*/
public function index(): array {
// Load all menu links below it.
$parameters = new MenuTreeParameters();
$parameters->setRoot('farm.setup')->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
$tree = $this->menuLinkTree->load(NULL, $parameters);
$manipulators = [
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
];
$tree = $this->menuLinkTree->transform($tree, $manipulators);
// Start cacheability for setup list.
$tree_access_cacheability = new CacheableMetadata();
// Build list item for each setup item.
$items = [];
foreach ($tree as $element) {
$tree_access_cacheability->addCacheableDependency($element->access);
if ($element->access->isAllowed()) {
$items[] = [
'title' => $element->link->getTitle(),
'description' => $element->link->getDescription(),
'url' => $element->link->getUrlObject(),
];
}
}
// Render items.
if (!empty($items)) {
$output = [
'#theme' => 'admin_block_content',
'#content' => $items,
];
}
else {
$output = [
'#markup' => $this->t('You do not have any setup items.'),
];
}
$tree_access_cacheability->applyTo($output);
return $output;
}
}