Skip to content

Instantly share code, notes, and snippets.

View flocondetoile's full-sized avatar

Flocon de toile flocondetoile

View GitHub Profile
<?php
/**
* @When I switch to the frame by selector "[title=:arg1]"
*/
public function switchToIFrameFromSelector($iframeSelector) {
$function = <<<JS
(function(){var iframe = document.querySelector("$iframeSelector");iframe.name = "iframeToSwitchTo";})()
JS;
try {
@flocondetoile
flocondetoile / MigrateAsymmetricToSymmetric.php
Created January 26, 2019 09:21 — forked from nikunjkotecha/MigrateAsymmetricToSymmetric.php
Code to migrate content from Asymmetric to Symmetric translations for paragraphs.
<?php
namespace Drupal\module\Helper;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\paragraphs\Entity\Paragraph;
/**
@flocondetoile
flocondetoile / macos_high_sierra_apache_php_brew_2018.md
Created September 25, 2018 13:49 — forked from karlhillx/macos_high_sierra_apache_php_brew_2018.md
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

@flocondetoile
flocondetoile / defcontent.sh
Created July 11, 2018 16:17 — forked from DuaelFr/defcontent.sh
Outputs the list of entity types and uuids contained by a content directory of a default_content module
#!/bin/bash
# How to use this script?
#
# 1. create an empty module that depends on default_content or reuse an
# existing one.
# 2. use `drush dcer --folder=path/to/module/content ENTITY_TYPE ID`
# to add default content to your module.
# 3. once all your content is in your module, clean up the content folder
# to only keep the content you need (ie. remove users most of the time).
@flocondetoile
flocondetoile / RecurringOrderManager.php
Created June 18, 2018 19:27 — forked from nikathone/RecurringOrderManager.php
Customization for revoking a subscription/Commerce recurring
<?php
namespace Drupal\custom_commerce_recurring;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\commerce_recurring\RecurringOrderManager as BaseRecurringOrderManager;
use Drupal\commerce_recurring\RecurringOrderManagerInterface;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@flocondetoile
flocondetoile / redis.conf
Created February 1, 2018 01:04 — forked from MaherSaif/redis.conf
Configuration for redis
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@flocondetoile
flocondetoile / drupal8.md
Created November 21, 2017 13:31
drupal d8
@flocondetoile
flocondetoile / mailhog.md
Created November 14, 2017 13:29 — forked from opi/mailhog.md
Install and configure MailHog (for Drupal) with a nice systemd unit and apache reverse proxy

MailHog (for Drupal) on Debian Stretch

MailHog is a nice mail testing tool for developers.

Website: https://github.com/mailhog/MailHog

Installation

Download the latest release on your local machine

@flocondetoile
flocondetoile / extra_field_token.php
Created November 10, 2017 13:30 — forked from opi/extra_field_token.php
Add a sub token for a node field
<?php
/**
* Implements hook_token_info_alter()
*/
function MODULE_token_info_alter(&$data) {
// Modify description of node tokens for our site.
$data['tokens']['node-field_myfield']['foo'] = [
'name' => "Foo",
'description' => "Process field_myfield value"
<?php
namespace Drupal\MY_MODULE\EventSubscriber;
use Drupal\Core\Session\AccountInterface;
use Drupal\taxonomy\TermInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;