Skip to content

Instantly share code, notes, and snippets.

@jacerider
jacerider / D8 | Programmatically Create Field.md
Last active February 15, 2024 01:37
Programmatically create a field in Drupal 8.
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;

$bundles = ['user'];

$fields['user_picture'] = [
  'type' => 'image',
  'entity_type' => 'user',
  'bundle' => 'user',
@jacerider
jacerider / D8 | Programmatically Remove Field.md
Last active May 30, 2023 11:53
Programmatically remove a field in Drupal 8.
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;

$bundles = ['user'];

$fields['user_picture'] = [
  'entity_type' => 'user',
];
@jacerider
jacerider / 01-README.md
Created May 2, 2018 17:01 — forked from petemcw/01-README.md
Mac OS X LEMP Configuration

Mac OS X LEMP Configuration

This Gist is a collection of configuration files that can be used to easily setup a Homebrew-based LEMP stack on Mac OS X.

Files in this repository are numbered and named for ordering purposes only. At the top of each file is a section of metadata that denote what component the file belongs to and the default name & location of the file. Feel free to implement it however you want.

Note: some configuration files have hard-coded paths to my user directory -- fix it for your setup

Setup

@jacerider
jacerider / wildcard
Last active February 7, 2018 17:18
Wildcard SSL generator for local dev
#!/bin/bash
set -e
#Set fonts for Help.
NORM=`tput sgr0`
BOLD=`tput bold`
REV=`tput smso`
SSL_PATH="${HOME}/Sites/ssl"
@jacerider
jacerider / jQuery | Plugin Boilerplate.js
Last active March 1, 2017 01:22
A jQuery Plugin Boilerplate
(function ($, Drupal, window, document) {
'use strict';
var pluginName = 'uxFormInput';
function Plugin(element, options) {
this.element = element;
this._name = pluginName;
@jacerider
jacerider / D8 | BlockPluginInstance.md
Created January 12, 2017 20:17
Create a block plugin instance directly and pass it the configuration
$configuration = [];
$variables['block_output'] = \Drupal::service('plugin.manager.block')
  ->createInstance($plugin_id, $configuration)
  ->build();
@jacerider
jacerider / D8 | BlockExisting.md
Last active January 12, 2017 20:09
D8 | Reuse an existing block
$block = \Drupal\block\Entity\Block::load('your_block_id');
$variables['block_output'] = \Drupal::entityTypeManager()
  ->getViewBuilder('block')
  ->view($block);