Skip to content

Instantly share code, notes, and snippets.

@dinarcon
dinarcon / mbe_book_paragraph.csv
Created August 15, 2017 02:22
Drupal 8 migrations by example
Professor ID Title Author
P01 The pushcart war Jean Merrill
P02 The definite guide to Drupal 7 Benjamin Melançon et al.
P03 The five love languages Gary Chapman
@dinarcon
dinarcon / nicaragua.module
Created November 7, 2017 14:20
Conditional fields in Paragraphs using the Javascript States API for Drupal 8
/**
* @file
* Example code from http://agaric.com/blogs/conditional-fields-paragraphs-using-javascript-states-api-drupal-8.
*/
/**
* Implements hook_field_widget_WIDGET_TYPE_form_alter().
*
* Example of conditional fields in paragraphs for Drupal 8.
*/
@dinarcon
dinarcon / migrate_plus.migration.omdb_json.yml
Last active July 3, 2022 11:03
Drupal 8 JSON Migration Example
# This is the *third* configuration to import with configuration type: 'Migration'
# This migration demonstrates importing from a monolithic JSON file.
# Forked from https://github.com/heddn/json_example_migrate/blob/json/web/modules/custom/custom_migrate/config/install/migrate_plus.migration.omdb_json.yml
uuid: b113ad9f-1ed7-43e5-802c-0e0270d2b7fa
id: omdb_json_article
label: JSON feed of movies (Article)
migration_group: json_example
source:
# We use the JSON source plugin.
plugin: url
@dinarcon
dinarcon / FeatureContext.php
Created April 11, 2019 20:15
Drupal 8 BDD with Behat
<?php
use Behat\Mink\Exception\ExpectationException;
use Behat\MinkExtension\Context\RawMinkContext;
// Located at ./features/bootstrap/
/**
* FeatureContext class defines custom step definitions for Behat.
*/
.
|-- core
|-- index.php
|-- modules
| `-- custom
| `-- ud_migrations
| `-- ud_migrations_first
| |-- migrations
| | `-- udm_first.yml
| `-- ud_migrations_first.info.yml
id: udm_process_intro
label: 'UD Process Plugins Introduction'
source: ...
process:
type: ...
title:
-
plugin: concat
source:
- first_name
process:
body/value: profile
body/format:
plugin: default_value
default_value: restricted_html
source:
defaults:
MY_VALUE: 'http://understanddrupal.com'
plugin: source_plugin_name
source_plugin_config: source_config_value
process:
process_destination: defaults/MY_VALUE
# 1) Run the migration.
$ drush migrate:import udm_process_intro
# 2) Some non recoverable error occurs. Check the status of the migration.
$ drush migrate:status udm_process_intro
# 3) Stop the migration.
$ drush migrate:stop udm_process_intro
# 4) Reset the status to idle.