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 / 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 / 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
@oksana-c
oksana-c / ExampleAttachTermsProgrammatically.php
Created October 4, 2018 17:15 — forked from dreambubbler/ExampleAttachTermsProgrammatically.php
Drupal 8: Attach terms to entity programmatically
<?php
use Drupal\node\Entity\Node;
/**
* Before attaching a term(s) to a term reference field,
* Must know:
* - field_example_name: the full name of the term reference field
* - tid: the term ID(s) to attach
*
* Keep in mind that this example uses Node::load()
@oksana-c
oksana-c / gen-d8-salt.sh
Created September 20, 2018 17:59 — forked from pfaocle/gen-d8-salt.sh
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@oksana-c
oksana-c / MODULENAME.install.php
Created August 29, 2018 21:56 — forked from daggerhart/MODULENAME.install.php
Drupal 8 file field to media entities simple migration. Does not move files in filesystem, just creates new media entities.
<?php
/**
* Create media entities from existing file fields.
*
* @link https://chromatichq.com/blog/migrating-drupal-file-fields-media-entities-without-migrate-module
*/
function MODULENAME_update_8001() {
// Nodes types that will get media migrated.
$node_types = ['article','event','page','session','sponsor'];
// Map old file fields => new media fields.
@oksana-c
oksana-c / any.php
Created August 20, 2018 17:24 — forked from robdecker/any.php
Drupal 7: Link l() function with attributes.
l(
t('<span></span>Link Title'),
'link_path',
array(
'attributes' => array(
'class' => array('menu-link'),
'id' =>'faq-page',
),
'html' => TRUE,
),
@oksana-c
oksana-c / gist:087a59fb3853cdab30d3dc6033edcc37
Created August 9, 2018 22:07 — forked from grasmash/gist:9746671
Behat FeatureContext.php for Drupal
<?php
use Drupal\DrupalExtension\Context\DrupalContext,
Drupal\DrupalExtension\Event\EntityEvent,
Drupal\Component\Utility\Random;
use Behat\Behat\Context\BehatContext,
Behat\Behat\Context\Step,
Behat\Behat\Context\Step\Given,
Behat\Gherkin\Node\PyStringNode,