Skip to content

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
b-khouy committed Jul 17, 2023
0 parents commit 20f0f39
Show file tree
Hide file tree
Showing 21 changed files with 1,555 additions and 0 deletions.
339 changes: 339 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions PATCHES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
Patches applied to this directory:

Drupal 10 compatibility
Source: https://www.drupal.org/files/issues/2022-12-29/block_list_override-3327993-5.patch


54 changes: 54 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
CONTENTS OF THIS FILE
---------------------

* Introduction
* Requirements
* Installation
* Configuration
* Maintainers


INTRODUCTION
------------

The Block List Override module removes unnecessary blocks from the block list for better system performance.

* For a full description of the module, visit the project page:
https://drupal.org/project/block_list_override

* To submit bug reports and feature suggestions, or to track changes:
https://drupal.org/project/issues/block_list_override


REQUIREMENTS
------------

This module requires no modules outside of Drupal core.


INSTALLATION
------------

* Install as you would normally install a contributed Drupal module. Visit:
https://www.drupal.org/node/1897420 for further information.
* If updating from the Block Blacklist module, leave Block Blacklist installed
while installing this module. The installation will detect the Block
Blacklist settings and copy them over. Confirm that the settings were copied
correctly then uninstall and remove Block Blacklist.

CONFIGURATION
-------------

1. Navigate to Administration > Extend and enable the module.
2. Navigate to Administration > Configuration > System > Block List Override Settings and list each name or value on a new line in the appropriate section. The user has the option to identify blocks to be removed or allowed by name or prefix, or provide a regex for more complex matching options.
3. Save.


MAINTAINERS
-----------

Current maintainers:
* Karen Stevenson (KarenS) - https://www.drupal.org/u/karens

This project is sponsored by:
* Lullabot - https://www.drupal.org/lullabot
12 changes: 12 additions & 0 deletions block_list_override.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Block List Override"
description: Remove unnecessary blocks from the block list for better system performance.
type: module
core_version_requirement: ^9.1 || ^10
dependencies:
- drupal:block
configure: block_list_override.settings

# Information added by Drupal.org packaging script on 2020-07-12
version: '1.0.1'
project: 'block_list_override'
datestamp: 1594592706
40 changes: 40 additions & 0 deletions block_list_override.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @file
* Contains block_list_override.install.
*/

/**
* Implements hook_install().
*/
function block_list_override_install() {
$found = FALSE;
$config_factory = \Drupal::configFactory();
$original = [
'block_blacklist.settings',
];
$values = [
'system_match',
'system_prefix',
'system_regex',
'layout_match',
'layout_prefix',
'layout_regex',
];
foreach ($original as $item) {
if ($config = $config_factory->getEditable($item)) {
$new_item = str_replace('block_blacklist', 'block_list_override', $item);
$new_config = $config_factory->getEditable($new_item);
foreach ($values as $value) {
$new_config->set($value, $config->get($value));
}
$new_config->save(TRUE);
$found = TRUE;
}
}
if ($found) {
$message = t('Block Blacklist configuration was discovered and is being used to create configuration for Block List Override. You can now uninstall the Block Blacklist module. Please check your settings and confirm they are correct.');
return $message;
}
}
7 changes: 7 additions & 0 deletions block_list_override.links.menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
block_list_override.settings:
title: 'Block List Override Settings'
route_name: block_list_override.settings
description: 'Remove blocks from the system.'
parent: system.admin_config_system
weight: 99

15 changes: 15 additions & 0 deletions block_list_override.links.task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
block_list_override.settings:
route_name: 'block_list_override.settings'
base_route: 'block_list_override.settings'
title: 'Settings'
weight: 0
block_list_override.system_list:
route_name: 'block_list_override.default_controller_list'
base_route: 'block_list_override.settings'
title: 'System Block List'
weight: 5
block_list_override.layout_list:
route_name: 'block_list_override.layout_controller_list'
base_route: 'block_list_override.settings'
title: 'Layout Builder Block List'
weight: 6
50 changes: 50 additions & 0 deletions block_list_override.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* @file
* Contains block_list_override.module.
*/

/**
* Implements hook_block_alter().
*/
function block_list_override_block_alter(&$definitions) {

$listService = \Drupal::service('block_list_override.list');
$settings = \Drupal::config('block_list_override.settings');
$options = [
'match' => trim($settings->get('system_match') ?? ''),
'prefix' => trim($settings->get('system_prefix') ?? ''),
'regex' => trim($settings->get('system_regex') ?? ''),
'negate' => !empty($settings) ? $settings->get('system_negate') : FALSE,
];
$listService->setUp($options);
if (!$listService->hasSettings()) {
return;
}
$callback = [$listService, 'blockIsAllowed'];
$definitions = array_filter($definitions, $callback, ARRAY_FILTER_USE_KEY);

}

/**
* Implements hook_plugin_filter_TYPE__CONSUMER_alter().
*/
function block_list_override_plugin_filter_block__layout_builder_alter(&$definitions) {

$listService = \Drupal::service('block_list_override.list');
$settings = \Drupal::config('block_list_override.settings');
$options = [
'match' => !empty($settings) ? trim($settings->get('layout_match')) : '',
'prefix' => !empty($settings) ? trim($settings->get('layout_prefix')) : '',
'regex' => !empty($settings) ? trim($settings->get('layout_regex')) : '',
'negate' => !empty($settings) ? $settings->get('layout_negate') : FALSE,
];
$listService->setUp($options);
if (!$listService->hasSettings()) {
return;
}
$callback = [$listService, 'blockIsAllowed'];
$definitions = array_filter($definitions, $callback, ARRAY_FILTER_USE_KEY);

}
4 changes: 4 additions & 0 deletions block_list_override.permissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
access block list override:
description: 'Access the Block List Override configuration pages.'
title: 'Access Block List Override'
restrict access: TRUE
27 changes: 27 additions & 0 deletions block_list_override.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
block_list_override.settings:
path: '/admin/config/block_list_override/settings'
defaults:
_form: '\Drupal\block_list_override\Form\SettingsForm'
_title: 'Block List Override'
requirements:
_permission: 'access block list override'
options:
_admin_route: TRUE
block_list_override.default_controller_list:
path: '/admin/config/block_list_override/system-list'
defaults:
_controller: '\Drupal\block_list_override\Controller\DefaultController::list'
_title: 'System Block List'
requirements:
_permission: 'access block list override'
options:
_admin_route: TRUE
block_list_override.layout_controller_list:
path: '/admin/config/block_list_override/layout-list'
defaults:
_controller: '\Drupal\block_list_override\Controller\LayoutController::list'
_title: 'Layout Builder Block List'
requirements:
_permission: 'access block list override'
options:
_admin_route: TRUE
4 changes: 4 additions & 0 deletions block_list_override.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
block_list_override.list:
class: Drupal\block_list_override\BlockListOverride
arguments: ['@entity_type.manager']
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "b-khouy/block_list_override",
"description": "Remove unnecessary blocks from the block list for better system performance.",
"type": "drupal-module",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/block_list_override",
"require": {
"drupal/core": "^9 || ^10"
}
}
9 changes: 9 additions & 0 deletions config/install/block_list_override.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
system_match: ''
system_prefix: ''
system_regex: ''
system_negate: false
layout_match: ''
layout_prefix: ''
layout_regex: ''
layout_negate: false

28 changes: 28 additions & 0 deletions config/schema/block_list_override.schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
block_list_override.settings:
type: config_object
label: 'Block List Override settings'
mapping:
system_match:
type: string
label: "Strings to match for system blocks"
system_prefix:
type: string
label: "Strings to use as prefixes for system blocks"
system_regex:
type: string
label: "Strings to use as regexes for system blocks"
system_negate:
type: boolean
label: "Negate option for system blocks"
layout_match:
type: string
label: "Strings to match for Layout Builder blocks"
layout_prefix:
type: string
label: "Strings to use as prefixes for Layout Builder blocks"
layout_regex:
type: string
label: "Strings to use as regexes for Layout Builder blocks"
layout_negate:
type: boolean
label: "Negate option for Layout Builder blocks"
Loading

0 comments on commit 20f0f39

Please sign in to comment.