Skip to content

Instantly share code, notes, and snippets.

View jonathanfranks's full-sized avatar

J F jonathanfranks

  • Breakthrough
  • Evanston, IL
View GitHub Profile
@jonathanfranks
jonathanfranks / behat.yml
Created June 24, 2015 18:25
Default formatter set to Progress in Behat 3.0 behat.yml
default:
formatters:
defaultFormat:
name: 'progress'
@jonathanfranks
jonathanfranks / gist:ec065382acb1c016329a
Created July 20, 2015 17:57
Manual clear flood table
$results = db_select('flood')->fields(NULL, array('expiration'))->execute()->fetchAll();
$count = count($results);
dpm($count);
db_delete('flood')
->execute();
$results = db_select('flood')->fields(NULL, array('expiration'))->execute()->fetchAll();
$count = count($results);
dpm($count);
@jonathanfranks
jonathanfranks / FormContext.php
Created August 12, 2015 15:05
Behat CKEditor
/**
* @Then /^I fill in wysiwyg field "([^"]*)" with "([^"]*)"$/
*/
public function iFillInWysiwygOnFieldWith($locator, $value) {
$el = $this->getSession()->getPage()->findField($locator);
$fieldId = $el->getAttribute('id');
if (empty($fieldId)) {
throw new Exception('Could not find an id for field with locator: ' . $locator);
}
@jonathanfranks
jonathanfranks / deletecookie.js
Created September 1, 2015 21:51
Delete Cookie by Name (JS)
var delete_cookie = function(name) {
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
};
delete_cookie('roundcube_sessauth');
@jonathanfranks
jonathanfranks / script.php
Created April 19, 2017 15:55
D8 refresh module config
$config_installer = \Drupal::service('config.installer');
$config_installer->installDefaultConfig('module', 'mymodule_name');
@jonathanfranks
jonathanfranks / gist:cd1344e5213aa42c6cc425201e6c0442
Created May 8, 2017 16:37
Drupal 8 Repository for Composer
composer config repositories.drupal composer https://packages.drupal.org/8
$migration_id = 'ncsbn_migrate_import_menu_items';
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
$executable = new \Drupal\migrate\MigrateExecutable($migration, new \Drupal\migrate\MigrateMessage());
$executable->import();
$uuid_service = \Drupal::service('uuid');
$uuid = $uuid_service->generate();
composer create-project drupal-composer/drupal-project:8.x-dev projectname --stability dev --no-interaction
@jonathanfranks
jonathanfranks / delete_field_instances.php
Created September 24, 2018 23:51
D8 - Delete all instances of a field in an entity type
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
$entity_type = 'node';
$bundles = entity_get_bundles('node');
$fields = ['field_phone', 'field_fax'];
foreach ($bundles as $bundle) {
foreach ($fields as $field_name) {
$field = FieldConfig::loadByName($entity_type, $bundle, $field_name);