Skip to content

Instantly share code, notes, and snippets.

View oksana-c's full-sized avatar

Oksana Cyrwus oksana-c

View GitHub Profile
@oksana-c
oksana-c / d8-composer-patch-without-version-update.md
Created March 16, 2020 21:47
Apply Drupal 8 patch using Composer without updating package version
  1. edit the composer.json file to add a patch.
"extra": {
    "enable-patching": true,
    "patches": {
        "drupal/core": {
            "<patch1 information>": "<patch1 file path>",
            "<patch2 information>": "<patch2 file path>"
 }
<?php
/**
* Sets an id for the first iframe situated in the element specified by id.
* Needed when wanting to fill in WYSIWYG editor situated in an iframe without identifier.
*
* @Given /^the iframe in element "(?P<element>[^"]*)" has id "(?P<id>[^"]*)"$/
*/
public function theIframeInElementHasId($element_id, $iframe_id) {
$function = <<<JS
{
"info": {
"_postman_id": "327e8396-b20c-49f7-8827-214aaa11203c",
"name": "GAO API for PR Tests",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "GAO Product Post",
"request": {
@oksana-c
oksana-c / gitflow-breakdown.md
Created April 22, 2019 23:17 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@oksana-c
oksana-c / migrate-way-1.php
Created February 17, 2019 20:06 — forked from labboy0276/migrate-way-1.php
Various Drupal 8 Body Migration Techniques Ways
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;
/**
* Implements hook_migrate_prepare_row().
*/
function YOUR_MODULE_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
switch ($migration->id()) {
case 'config_name':
@oksana-c
oksana-c / FCEntityMigrate.php
Created January 7, 2019 21:33 — forked from teglia/FCEntityMigrate.php
Migrating Field Collections to Paragraphs on an empty Drupal 8 site WITHOUT migrate_tools or migrate_plus
<?php
namespace Drupal\migrate_custom\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Drupal 7 file source from database.
@oksana-c
oksana-c / import.php
Created November 17, 2018 18:10 — forked from crittermike/import.php
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
// Or, import YAML config an arbitrary directory.
@oksana-c
oksana-c / alter_solarium_query.php
Last active November 13, 2024 11:09
Search API Solr - hook_search_api_solr_converted_query_alter()
<?php
/**
* Implements hook_search_api_solr_converted_query_alter().
*
* Modifies Solarium query to group results by field.
* Modifies Solarium query to sort results by first geofield value within the multivalue field.
*/
function MODULE_search_api_solr_converted_query_alter(\Solarium\Core\Query\QueryInterface $solarium_query, \Drupal\search_api\Query\QueryInterface $query) {
// Alter the Solarium query.
@oksana-c
oksana-c / d8-preprocess-process-hooks.md
Last active November 8, 2018 22:07
D8: Defining preprocess & process hooks

contents of the theme/preprocess/README.md

Defining preprocess hooks

Rather than placing your preprocess hooks directly in the .theme file you can manage them in automatically discovered and lazy-loaded include files. It is even possible to organize them in sub-folders. This feature greatly improves the maintainability of large themes that would otherwise contain hundreds of lines of unrelated code in your template.php file.

@oksana-c
oksana-c / MyService.php
Created October 29, 2018 22:47 — forked from JeffTomlinson/MyService.php
Drupal 8 Configuration Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Config\ConfigFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services