Skip to content

Instantly share code, notes, and snippets.

View filipengberg's full-sized avatar

Filip Engberg filipengberg

View GitHub Profile
[2016-03-23 23:00:12.072593] [info] Results:
CUSTOMER: '10 files'
ITEM: '3 files'
@filipengberg
filipengberg / hide_untranslated.php
Created March 16, 2016 08:05
Drupal 8 module that hides entities that has no translation in the currently viewed language. Also redirects untranslated node views to frontpage
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Url;
/**
@filipengberg
filipengberg / EventSubscriber.php
Created March 11, 2016 15:59
Drupal 8 EventSubscriber that sets the category field based on entity browser id
<?php
/**
* @file
* Contains \Drupal\image_library\EventSubscriber.
*/
namespace Drupal\image_library\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@filipengberg
filipengberg / ViewSelection.php
Last active December 22, 2015 15:16
Drupal 8: DefaultSelection Plugin subclass for filtering selectable Views by tag
<?php
/**
* @file
* Contains \Drupal\example\Plugin\EntityReferenceSelection\ViewSelection.
*/
namespace Drupal\example\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;