Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
mathiasverraes / max.php
Created December 9, 2014 19:40
max($list, $function) in php
<?php
// test data
class Foo {
private $a;
private $b;
function __construct($a, $b)
{
@timplunkett
timplunkett / setupd8
Last active January 7, 2019 21:02
Reinstall D8
#!/bin/bash
PROFILE="standard"
DB="d8"
UI=false
NO_DEV=false
OPTS=`getopt -o h --longoptions db:,profile:,ui,no-dev -- "$@"`
eval set -- "$OPTS"
while true; do
@facelordgists
facelordgists / delete-git-recursively.sh
Created May 13, 2015 05:28
Recursively remove .git folders
( find . -type d -name ".git" && find . -name ".gitignore" && find . -name ".gitmodules" ) | xargs rm -rf
@facine
facine / __INDEX.txt
Last active August 6, 2023 15:33
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@bojanz
bojanz / extension-patterns.md
Last active January 14, 2023 16:59
Extension patterns: events, tagged services, plugins

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".
@keopx
keopx / Vagrant_nfs_debian8.sh
Last active December 10, 2015 16:00
Vagrant NFS in Debian 8
sudo su
modprobe nfsd
# https://bugzilla.mozilla.org/show_bug.cgi?id=1056049#c8
systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
@chris-hall-hu
chris-hall-hu / sql.sql
Created January 2, 2016 08:45
Example sql migration for late Beta Drupal 8 to 8.01
-- Commands run whilst in the new database, the original datbase is call 'old'
-- NOTE this is an example original table etc. will need to be investigate with describe etc.
INSERT INTO taxonomy_index SELECT * FROM old.taxonomy_index;
INSERT INTO taxonomy_term_data SELECT * FROM old.taxonomy_term_data;
INSERT INTO taxonomy_term_field_data SELECT * FROM old.taxonomy_term_field_data;
INSERT INTO taxonomy_term_hierarchy SELECT * FROM old.taxonomy_term_hierarchy;
INSERT INTO node SELECT nid, vid, type, uuid, 'en' FROM old.node;
INSERT INTO node__body SELECT * FROM old.node__body;
@rwitchell
rwitchell / FacebookConnectController.php
Created May 23, 2016 14:28
oauth2-client-bundle install example
<?php
namespace Comp\AppBundle\Controller;
use Comp\AppBundle\Entity\User;
use Comp\AppBundle\Form\FacebookRegistrationType;
use League\OAuth2\Client\Provider\FacebookUser;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
@mortenson
mortenson / composer.json
Last active August 20, 2023 10:39
Example composer.json file for File Browser
{
"name": "mortenson/example",
"minimum-stability": "dev",
"authors": [
{
"name": "Samuel Mortenson",
"email": "samuel.mortenson@acquia.com"
}
],
"repositories": [
@liberatr
liberatr / create_file.php
Last active September 20, 2016 05:48
Programmatically save a file to Drupal from your local file system.
/**
* Saves a file on your local file system you want to copy to Drupal default files directory.
* This assumes you have bootstrapped Drupal.
* Originally written to be invoked within a Behat context.
*/
use Drupal\file\Entity\File;
$file = File::create([
'uid' => 1
]);