Skip to content

Instantly share code, notes, and snippets.

View mattschaff's full-sized avatar

Matt Schaff mattschaff

View GitHub Profile
@mattschaff
mattschaff / MyModuleQueueEvent.php
Created April 4, 2019 13:45
Drupal 8: Custom queue worker processed by cron
<?php
/**
* @file
* Contains \Drupal\my_module\Plugin\QueueWorker\MyModuleQueueEvent.
*/
namespace Drupal\my_module\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
@mattschaff
mattschaff / ExampleCrudAdminForm.php
Created December 12, 2019 22:31
Drupal 8: CRUD admin form (AJAX add, delete)
<?php
namespace Drupal\example\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@mattschaff
mattschaff / MigrateEntityReference.php
Created December 12, 2019 22:48
Drupal 8: Drush 9 command to migrate an entity reference from a paragraph field to a node field
<?php
/*
* Place this file at src/Commands/MigrateEntityReference.php in your custom module directory.
*/
namespace Drupal\exmample\Commands;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
@mattschaff
mattschaff / example.theme.php
Created December 12, 2019 22:55
Drupal 8: Add unique ID to theme suggestions for form elements
<?php
/**
* @file
*/
/**
* Implements hook_form_alter()
*/
// Add unique form ID to theme suggestions for form elements.