Skip to content

Instantly share code, notes, and snippets.

View liberatr's full-sized avatar

Ryan Price liberatr

View GitHub Profile
@liberatr
liberatr / my_module.module
Last active September 23, 2022 22:24 — forked from reinis-kinkeris/my_module.module
Drupal 8 - Example of adding dynamic js libraries which require locale
/**
* Implements hook_library_info_build().
*
* @return array
*/
function mymodule_library_info_build() {
$libraries = [];
$api_key = \Drupal::config('mymodule.api_key');
@liberatr
liberatr / Debug
Last active August 28, 2021 00:08
A Drupal 8 migrate processor plugin for debugging
<?php
namespace Drupal\uwec_migration\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* This plugin allows your migration to spit the value to the command line.
@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
]);
@liberatr
liberatr / setlangcode.drush.inc
Last active September 22, 2017 17:08 — forked from lipcpro/setlangcode.drush.inc
D7: drush command to list content types available and set the language code for a certain type
<?php
/**
* Implements hook_drush_command().
*/
function setlangcode_drush_command() {
$items = array();
// The 'setlangcode' command.
$items['setlangcode'] = array(
'description' => "Sets the language code for certain types of entities.",