Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar
git reset --soft HEAD~1

Norman Kämper-Leymann leymannx

git reset --soft HEAD~1
View GitHub Profile
leymannx /
Created May 19, 2021 13:15
Drush generate field formatter
drush generate plugin-field-formatter
leymannx / my-drupal-scaffold.json
Last active January 28, 2020 10:08
Drupal Composer prevent .htaccess or from being overwritten using drupal/core-composer-scaffold
View my-drupal-scaffold.json
"drupal-scaffold": {
"locations": {
"web-root": "web/"
"file-mapping": {
"[web-root]/.htaccess": false,
"[web-root]/sites/": false
leymannx / SiteLogoBlock.php
Created October 18, 2019 07:33
Drupal 8 file upload block
View SiteLogoBlock.php
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\file\Entity\File;
use Drupal\file\FileUsage\FileUsageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
leymannx / gulpfile.js
Last active December 7, 2022 10:57
Gulp 4 Sass BrowserSync Kickstart Example
View gulpfile.js
// Requires Gulp v4.
// $ npm uninstall --global gulp gulp-cli
// $ rm /usr/local/share/man/man1/gulp.1
// $ npm install --global gulp-cli
// $ npm install
const { src, dest, watch, series, parallel } = require('gulp');
const browsersync = require('browser-sync').create();
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
leymannx /
Created October 22, 2018 08:16 — forked from swichers/
Drupal 7 - Programmatically add view mode to entity

In a module file:

This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.

 * Implements hook_entity_info_alter().
function HOOK_entity_info_alter(&$entity_info) {
leymannx / DownloadSlidesFormatter.php
Last active August 2, 2018 15:42
Field formatter snippet for the fully working sample module on
View DownloadSlidesFormatter.php
namespace Drupal\mffe\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\media\Entity\Media;
use Drupal\file\Entity\File;
use Drupal\Core\Url;
leymannx /
Last active May 26, 2023 16:58
iTerm2 Solarized Dark theme + Fish shell + oh-my-fish /// macOS High Sierra
View docker-compose.yml
version: '2'
image: php:7.0-apache
- /var/www/myapp