Skip to content

Instantly share code, notes, and snippets.

View Berdir's full-sized avatar

Sascha Grossenbacher Berdir

View GitHub Profile
alias mrn='curl "https://api.drupal-mrn.dev/changelog?project=${PWD##*/}&to=`git tag --sort=committerdate | tail -1`&from=`git tag --sort=committerdate | tail -2 | head -1`&format=html"'
@Berdir
Berdir / Dockerfile
Created February 1, 2023 22:00
ddev relay
# .ddev/web-build/Dockerfile
# You can copy this Dockerfile.example to Dockerfile to add configuration
# or packages or anything else to your webimage
ARG BASE_IMAGE
FROM $BASE_IMAGE
# Add Relay repository
RUN wget -q "https://repos.r2.relay.so/key.gpg" -O- | apt-key add -
RUN echo "deb https://repos.r2.relay.so/deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
@Berdir
Berdir / example
Last active October 26, 2022 20:44
Alias for drupal-mrn.dev
$ mrn
<p><em>Add a summary here</em></p>
<h3>Contributors (1)</h3>
<p><a href="https://www.drupal.org/u/tim.plunkett">tim.plunkett</a></p>
<h3>Changelog</h3>
<p><strong>Issues:</strong> 1 issues resolved.</p>
<p>Changes since <a href="https://www.drupal.org/project/currency/releases/8.x-3.3">8.x-3.3</a>:</p>
<h4>Task</h4>
<ul>
<li><a href="https://www.drupal.org/i/3223997">#3223997</a> by tim.plunkett: Allow PHP 8, Drupal 10 compatibility</li>
# Completely flush redis, old stuff is no longer relevant and wastes space, avoids any
# old state to influence update functions.
./vendor/bin/drush ev "\Drupal::service('redis.factory')->getClient()->flushAll()"
# Check if there are any updates to run.
if [ -n "$(./vendor/bin/drush updbst --format=list 2>/dev/null)" ]; then
# If so, then drush updb includes a drush cr, but separately clear css/js cache
# because due to memory cache backend during updates, it does not invalidate things properly.
./vendor/bin/drush updb -y
./vendor/bin/drush cc css-js
else
_meta:
entity_type: node
bundle: paragraphed_content_demo
uuid: 1e6ebc61-4d0f-4b59-a4f0-f83d15a6a87d
depends:
f75d2dbe-990c-4fe6-9fb8-aeecbb6579a9: user
a42417d1-0d90-495d-8f2d-8ec36e4ddbd9: paragraphs_library_item
default:
langcode:
-
<?php
namespace Drupal\yourmodule\EventSubscriber;
use Drupal\Core\Cache\CacheableResponseInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
"Language label logic when installing with language, adding and editing languages is confusing #2927338": "https://www.drupal.org/files/issues/2019-03-15/language-labels-2927338-19.patch",
"Make language switcher block cacheable #2232375": "https://www.drupal.org/files/issues/2232375-54_0.patch",
"2978048: Unpublished translations should fallback to the original language": "https://www.drupal.org/files/issues/2018-06-07/unpublished-translation-fallback-2978048-3.patch",
"2971390: Disallow users to change content translation uid metadata field": "https://www.drupal.org/files/issues/2019-03-15/2971390-39.patch",
"2546212: Entity view/form mode formatter/widget settings have no translation UI": "https://www.drupal.org/files/issues/2019-03-10/2546212-108.patch",
"2155787: Introduce more flexible access control for content translation operations": "patches/2155787-34-rebased-on-top-of-2972308-17.patch",
"3002571: Multiple warning messages when having untranslatable fields": "https://www.drupal.org/files/issues/201
@Berdir
Berdir / regex
Created January 18, 2019 21:46
Remove debug output from d.o test results
^http://php-apache-jenkins.+\.html\n
<?php
public getRevisionDefaultMetadataKey() {
$revision_metadata_keys = $entity_type->getRevisionMetadataKeys(FALSE);
return isset($revision_metadata_keys['revision_default']) ? $revision_metadata_keys['revision_default'] : 'revision_default';
}
# How to force disable interface translation by overriding the locale lookup service to not be added to the translation manager
# settings.local.php:
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/services.local.yml';
# services.local.yml (add this file to .gitignore):
services:
string_translator.locale.lookup:
class: Drupal\locale\LocaleTranslation