Skip to content

Instantly share code, notes, and snippets.

@hudri
hudri / webform.contact.yml
Created September 15, 2020 08:45
Webform with processed text causing extra DIV wrapper
uuid: 8b7b6e7f-dab7-446e-b640-37a3d6efb6bd
langcode: de
status: open
dependencies:
enforced:
module:
- webform
open: null
close: null
weight: 0
@hudri
hudri / gist:4cb05bd631ef53fa28ca80341f73b8da
Created August 24, 2020 11:04
Drupal Form with multiple submit buttons in a table
<?php
namespace Drupal\wt_pricetable\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\Component\Render\FormattableMarkup;
./drs php-eval '$query = \Drupal::entityTypeManager()->getStorage("node")->getQuery();
$query->condition("type", ["wt_room", "wt_package"], "IN");
$nodeIds = $query->execute();
$hotelEntities = \Drupal::entityTypeManager()->getStorage("node")->loadMultiple($nodeIds);
foreach ($hotelEntities as $hotelEntity) {
$hotelEntity->set("remote_datasource", "KOGNITIV");
$hotelEntity->save();
}'
@hudri
hudri / insert_default_paragraphs_field_value.sql
Created May 29, 2018 14:02
Drupal 8: Insert default values for in newly added paragraphs fields
insert into paragraph__FIELD_NEWFIELD (bundle, deleted, entity_id, revision_id, langcode, delta, FIELD_NEWFIELD_value)
select type, 0, id, revision_id, langcode, 0, DEFAULT_FIELD_VALUE from paragraphs_item where type = 'PARENT_PARAGRAPH_TYPE';
insert into paragraph_revision__FIELD_NEWFIELD (bundle, deleted, entity_id, revision_id, langcode, delta, FIELD_NEWFIELD_value)
select type, 0, id, revision_id, langcode, 0, DEFAULT_FIELD_VALUE from paragraphs_item where type = 'PARENT_PARAGRAPH_TYPE'
@hudri
hudri / library.scss
Created May 7, 2018 09:16 — forked from certainlyakey/library.scss
URL-encode color SASS function / convert color to hex SASS function
//does not work with colors containing alpha
@function encodecolor($string) {
@if type-of($string) == 'color' {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
}
$string: '%23' + $string;
@return $string;
}
@hudri
hudri / LinkModifierService.php
Last active April 19, 2018 14:59
Modify _all_ Drupal links
<?php
namespace Drupal\wt_base;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Class DefaultService.
@hudri
hudri / fa5_symbol.sh
Last active March 23, 2018 16:28
Turn FontAwesome5 raw <svg>s into <symbol>s
cd advanced-options/raw-svg/regular
# prefix filenames with 'far-' so we could mix icons from different style set
rename 's/^/far-/' *.svg
# change opening tag '<svg xmlsn="http://www.w3.org/2000/svg"' into ' <symbol id="current-filename.svg"'
perl -i -pe 's/<svg xmlns="http:\/\/www.w3.org\/2000\/svg"/ <symbol id="$ARGV"/g' *.svg
# remove the trailng '.svg' from the id
perl -i -pe 's/\.svg"/"/g' *.svg
# change closing tag from '</svg>' to '</symbol>'
perl -i -pe 's/<\/svg>/<\/symbol>/g' *.svg
# go into next style directory, repeat with different filename prefix