Skip to content

Instantly share code, notes, and snippets.

View vever001's full-sized avatar

Hervé Donner vever001

  • Brussels, Belgium
View GitHub Profile
@vever001
vever001 / all-day-fix.patch
Created January 29, 2024 21:40
All day fix for patie/calendar-links
diff --git a/src/Generators/Google.php b/src/Generators/Google.php
index 5ff4fe6..0acfa41 100644
--- a/src/Generators/Google.php
+++ b/src/Generators/Google.php
@@ -21,10 +21,8 @@ public function generate(Link $link): string
{
$url = 'https://calendar.google.com/calendar/render?action=TEMPLATE';
- $utcStartDateTime = (clone $link->from)->setTimezone(new DateTimeZone('UTC'));
- $utcEndDateTime = (clone $link->to)->setTimezone(new DateTimeZone('UTC'));
<?php
namespace Drupal\f_search\Plugin\search_api\processor;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Plugin\PluginFormTrait;
use Drupal\search_api\Processor\ProcessorPluginBase;
@vever001
vever001 / Highlight.php
Created March 23, 2021 16:20
Performance issue with search_api's Highlight processor
<?php
namespace Drupal\mymodule\Plugin\search_api\processor;
use Drupal\search_api\Plugin\search_api\processor\Highlight;
/**
* Extends Search API default Highlight processor.
*/
class SolrHighlight extends Highlight {
<?php
/**
* Implements hook_theme_element_info_alter().
*/
function mytheme_element_info_alter(array &$info) {
if (isset($info['processed_text'])) {
$info['processed_text']['#pre_render'][] = '_mytheme_pre_render_element_processed_text';
}
}
@vever001
vever001 / fix_body_revisions.php
Created June 5, 2020 17:58
Run this using "drush php-script fix_body_revisions.php"
<?php
$query = db_select('field_data_body', 'cur');
$query->join('field_revision_body', 'rev', 'rev.entity_id = cur.entity_id AND rev.revision_id = cur.revision_id');
$query->where('rev.body_value != cur.body_value')
->fields('cur');
$results = $query->execute()->fetchAllAssoc('entity_id');
foreach ($results as $result) {
$entity_type = $result->entity_type;
@vever001
vever001 / efe_migrate.views.inc
Created May 21, 2019 15:31
Views integration with migrate_map_* tables
<?php
/**
* @file
* Contains hooks for Views.
*/
use Drupal\migrate\Plugin\migrate\id_map\Sql;
/**
@vever001
vever001 / gist:38b031ee83eec8f0fe375718fa1b9f3d
Created May 17, 2016 15:37
Drupal 7 - Create vocabulary and terms (hierarchical terms allowed) programmatically.
/**
* Creates a vocabulary given a machine name if it doesn't exist yet.
*
* @param string $machine_name
* The machine name of the vocabulary.
*
* @return object
* A vocabulary object.
*/
function _mymodule_create_vocabulary($machine_name) {