Skip to content

Instantly share code, notes, and snippets.

View andybroomfield's full-sized avatar

Andy Broomfield andybroomfield

View GitHub Profile
@andybroomfield
andybroomfield / FilterConfigSubscriber.php
Created September 20, 2023 08:25
Eventsubscriber to sort text format filters alphapetically in config (still sorted by weight in the filter format itself)
<?php
namespace Drupal\filter_format_config_sort\EventSubscriber;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\StorageTransformEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
@andybroomfield
andybroomfield / migrate_plus.migration.menu_links.yml
Last active September 26, 2021 13:40
Migrate Drupal 8/9 Menu items into a new Drupal 9 site using migrate_drupal_d8 (seperate databases)
@andybroomfield
andybroomfield / services-menu-accessibility.js
Created July 1, 2021 08:48
BHCC Services mega menu tabbing order
/**
* Accessibility tabbing support for servies megamenu
*/
(function($) {
/**
* Check Key pressed is Tab Key
* @param {Event} e jQuery keypress event
* @return {Boolean}
@andybroomfield
andybroomfield / core.entity_form_display.node.localgov_services_page.default.yml
Last active November 12, 2020 11:39
Field config for test distro field to amend localgov_services_page
langcode: en
status: true
dependencies:
config:
- field.field.node.localgov_services_page.body
- field.field.node.localgov_services_page.field_common_tasks
- field.field.node.localgov_services_page.field_download_links
- field.field.node.localgov_services_page.field_hide_related_topics
- field.field.node.localgov_services_page.field_override_related_links
- field.field.node.localgov_services_page.field_page_components
/**
* Determine if an element is visible by checking visiblity of parents.
*
* A helper around
* \Drupal::service('webform_submission.conditions_validator')->isElementVisible
* @param Array $element
* Webform element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Form state object.
* @param Array $complete_form
@andybroomfield
andybroomfield / tasty_backend_check_manage_view_exists.patch
Created January 22, 2020 12:01
Patch for skiping over the tasty backend duplicate view if main tb manage content view does not exist yet (Fix install site from config)
diff --git a/src/TastyBackendManager.php b/src/TastyBackendManager.php
index 28bb212..a06c4c1 100644
--- a/src/TastyBackendManager.php
+++ b/src/TastyBackendManager.php
@@ -54,28 +54,31 @@ class TastyBackendManager extends SystemManager {
'plugin_id' => 'bundle',
'group' => 1,
];
-
+
@andybroomfield
andybroomfield / anchor_link_support_3015301-5--for-non-dev.patch
Last active September 17, 2019 14:44
View ajax history (D8) patch for fragment support (reroll)
@andybroomfield
andybroomfield / 2907094_tabs_field_group_support.patch
Created May 19, 2019 01:02
Patch for Drupal Paragrams with field group horizontal tabs
diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
index ce8d108..2d9bda9 100644
--- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -643,7 +643,7 @@ class InlineParagraphsWidget extends WidgetBase {
];
field_group_attach_groups($element['subform'], $context);
- $element['subform']['#pre_render'][] = 'field_group_form_pre_render';
+ $element['subform']['#process'][] = 'field_group_form_process';
@andybroomfield
andybroomfield / metaweather.php
Last active December 2, 2018 11:09
Metaweather.com API proxy to implement cache and CORS headers
<?php
define ('API_URI_BASE', 'https://www.metaweather.com/api/');
define ('CACHE_DIR', 'metaweather-cache');
define ('CACHE_TIME', 3600);
// Create Cache Directory
$cache_name = sha1($_SERVER['REQUEST_URI']);
if (!is_dir(CACHE_DIR)) {
@andybroomfield
andybroomfield / s3.php
Created May 4, 2018 10:12
Patching Codeigniter s3 library to work with AWS4-HMAC-SHA256
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* $Id: S3.php 47 2009-07-20 01:25:40Z don.schonknecht $
*
* Copyright (c) 2008, Donovan Schönknecht. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*