Skip to content

Instantly share code, notes, and snippets.

View heddn's full-sized avatar

Lucas Hedding heddn

View GitHub Profile
langcode: en
status: true
dependencies: { }
id: upgrade
label: 'Import from Database'
description: 'Migrations originally generated from drush migrate-upgrade --configure-only'
source_type: 'Drupal 7'
module: null
shared_configuration:
source:
```
Foo```
public function testFieldProviderCore() {
/** @var \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migrate.field');
$this->setExpectedException(InvalidPluginDefinitionException::class, 'The missing_core plugin should define the core property.');
$this->setExpectedException(InvalidPluginDefinitionException::class, 'The missing_source plugin should define the source_module property.');
$this->setExpectedException(InvalidPluginDefinitionException::class, 'The missing_destination plugin should define the destination_module property.');
$plugin_manager->getDefinition('missing_core');
$plugin_manager->getDefinition('missing_source');
$plugin_manager->getDefinition('missing_destination');
}
class CartOnlySingleItem implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
CartEvents::CART_ENTITY_ADD => ['limitNumberEntriesAdd'],
"require-dev": {
"drupal/coder": "^8.2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"phpmd/phpmd": "^2.6",
"phpro/grumphp": "^0.11.6",
"phpunit/phpunit": "^5",
"sebastian/phpcpd": "^3.0",
"sensiolabs/security-checker": "^4.1"
},
// For anonymous users, we need to start session before storing in private
// temp store, otherwise a new session_id will be created each page view
// and the preious private store values will be inaccessible.
if ($this->currentUser->isAnonymous() && !$this->request->getSession()->get('session_started')) {
$this->request->getSession()->set('session_started', TRUE);
$this->sessionManager->start();
}
@heddn
heddn / PurchaseBuildRegistration.php
Created July 6, 2017 17:52
RNG Commerce integration
<?php
namespace Drupal\custom_module\EventSubscriber;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\rng\RegistrantFactoryInterface;
use Drupal\state_machine\Event\WorkflowTransitionEvent;
/**
* {@inheritdoc}
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
// Loop over each of the definitions and categorize it as config or content.
if (!empty($definition['class'])) {
$configuration_classes = [
EntityConfigBase::class,
* The key of the array might to be changed. In this case, the new id property needs to be the key.
* It'd be possible to just add key: "@id" to the iterator process but that
* would require special casing the key property and somehow escape it when
* there is actually a destination called key. Instead, it is moved out of the
* process and key is in the configuration of iterator itself:
* @code
* process:
* filters:
* plugin: iterator
* source: filters
SELECT DISTINCT field_data_field_referring_domain0.entity_type AS entity_type, field_data_field_referring_domain0.entity_id AS entity_id, field_data_field_referring_domain0.revision_id AS revision_id, field_data_field_referring_domain0.bundle AS bundle
FROM
{field_data_field_referring_domain} field_data_field_referring_domain0
INNER JOIN {field_data_field_referring_domain} field_data_field_referring_domain1 ON field_data_field_referring_domain1.entity_type = field_data_field_referring_domain0.entity_type AND field_data_field_referring_domain1.entity_id = field_data_field_referring_domain0.entity_id
INNER JOIN {field_data_field_referring_domain} field_data_field_referring_domain2 ON field_data_field_referring_domain2.entity_type = field_data_field_referring_domain0.entity_type AND field_data_field_referring_domain2.entity_id = field_data_field_referring_domain0.entity_id
INNER JOIN {field_data_field_referring_domain} field_data_field_referring_domain3 ON field_data_field_referring_domain3.entity_type = field_