Skip to content

Instantly share code, notes, and snippets.

View adamzimmermann's full-sized avatar

Adam Zimmermann adamzimmermann

View GitHub Profile
@adamzimmermann
adamzimmermann / migrate.sh
Last active March 11, 2024 11:08
Migration Script with Limit/Looping
#!/bin/bash
migrate_loop()
{
# Better readability with separation.
echo "========================";
# Get the output of the drush status.
drush_output=$(drush ms "$1" --format string);
# Split output string into an array.
@adamzimmermann
adamzimmermann / example_module.install
Last active March 21, 2022 19:41
Update hooks to convert menu paths to entity routes
/**
* @file
* This gist supports the following article:
* https://chromatichq.com/insights/managing-large-menus-memory-usage-during-drupal-cache-clears
*/
/**
* Converts menu content links to the new format that avoids the need to rebuild
* them during a cache rebuild.
*
@adamzimmermann
adamzimmermann / FilterImageToken.php
Created May 18, 2021 12:32
Converts custom media tokens into responsive images.
<?php
namespace Drupal\chromatic_image\Plugin\Filter;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
@adamzimmermann
adamzimmermann / ExampleMigrateSourceImage.php
Created August 15, 2016 19:31
Drupal Migrate class for using images as a migration source.
<?php
/**
* Source Migration class for finding image tags in markup.
*/
class ExampleMigrateSourceImage extends MigrateSource {
/**
* The string of HTML content.
*/
@adamzimmermann
adamzimmermann / ExampleImageMigration.php
Last active August 15, 2016 19:31
Drupal Migrate class for creating image entities.
<?php
/**
* Migrate images into entities.
*/
class ExampleImageMigration extends Migration {
/**
* {@inheritdoc}
*/
@adamzimmermann
adamzimmermann / example_wordpress_migrate.drush.inc
Created August 24, 2015 14:11
Programatically Creating and Storing WordPress Migrate Migrations in Drupal
/**
* Define the WordPress blogs to be imported.
*/
function example_wordpress_migrate_wordpress_blogs() {
// Any key not set here will default to the values set in the
// $blog_default_settings variable in the drush command.
$blogs = array(
array(
'domain' => 'www.example.com/site-one/',
),