Skip to content

Instantly share code, notes, and snippets.

Avatar
💤

Rakesh James rakeshjames

💤
View GitHub Profile
View demouser_migrate_multipleRoles.csv
ID name email firstname lastname Status roles Password
1 rakesh rakesh.james@gmail.com Rakesh James 1 administrator,migrationuser rakesh@123
2 james james.rakesh@gmail.com James Rakesh 1 authenticated james@123
3 dummy dummy@gmail.com Dummy User 1 migrationuser,administrator dummy@123
View demo_user_migrate.yml
id: demo_user_migration
migration_tags: null
migration_group: null
label: 'User migration from CSV'
source:
plugin: csv
path: /Library/WebServer/Documents/d8/sites/default/files/demousers_migrate.csv
header_row_count: 1
keys:
- ID
View demousers_migrate.csv
ID name email firstname lastname Status roles
1 rakesh rakesh.james@gmail.com Rakesh James 1 administrator
2 james james.rakesh@gmail.com James Rakesh 1 authenticated
3 dummy dummy@gmail.com Dummy User 1 testuser
View example_events.services.yml
services:
example_events.event_subscriber_example:
class: Drupal\example_events\EventSubscriber\ExampleEventSubScriber
tags:
- { name: 'event_subscriber' }
View ExampleEventSubscriber.php
<?php
/**
* @file
* Contains \Drupal\example_events\ExampleEventSubScriber.
*/
namespace Drupal\example_events\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
View DemoEventDispatchForm.php
<?php
/**
* @file
* Contains \Drupal\example_events\Form\DemoEventDispatchForm.
*/
namespace Drupal\example_events\Form;
use Drupal\Core\Form\FormBase;
@rakeshjames
rakeshjames / example_dispatching_an_example_event.php
Created Jul 14, 2016
Example for how to dispatch an example event in Drupal 8?
View example_dispatching_an_example_event.php
<?php
// Following is the example for How to dispatch an event in Drupal 8?
// Use the namespace of the ExampleEvent class
use Drupal\example_events\ExampleEvent;
// load the Symfony event dispatcher object through services
$dispatcher = \Drupal::service('event_dispatcher');
// creating our event class object.
View ExampleEvent.php
<?php
namespace Drupal\example_events;
use Symfony\Component\EventDispatcher\Event;
class ExampleEvent extends Event {
const SUBMIT = 'event.submit';
protected $referenceID;