Skip to content

Instantly share code, notes, and snippets.

@neetumorwani
neetumorwani / module.php
Created April 5, 2018 07:59 — forked from gwagroves/module.php
Drupal 8 Paragraphs: Add a theme suggestion based on the paragraph and the type of the current node.
<?php
/**
* Implements theme_suggestions_HOOK_alter().
*/
function mytheme_theme_suggestions_paragraph_alter(array &$suggestions, array $variables) {
if ($node = \Drupal::routeMatch()->getParameter('node')) {
$paragraph = $variables['elements']['#paragraph'];
array_push($suggestions, 'paragraph__' . $paragraph->getType() . '__' . $node->getType());
}
}
@neetumorwani
neetumorwani / mymodule.js
Created December 18, 2017 07:42 — forked from SebCorbin/mymodule.js
Using highcharts with Drupal 7
(function ($) {
Drupal.behaviors.mymodule_charts = {
attach:function () {
if (Drupal.settings.mymodule.charts) {
for (var chart in Drupal.settings.mymodule.charts) {
new Highcharts.Chart(Drupal.settings.mymodule.charts[chart]);
}
}
}
};
<?php
/**
* @file
* Contains Drupal\akamai\Plugin\Purge\Purger\AkamaiPurger.
*/
namespace Drupal\akamai\Plugin\Purge\Purger;
use Drupal\purge\Plugin\Purge\Purger\PurgerBase;
use Drupal\purge\Plugin\Purge\Purger\PurgerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
$purgeQueue = \Drupal::service('purge.queue');
$items = $purgeQueue->claim();
$newitems = array();
$uris = array();
foreach($items as $item) {
if($item->getPluginId()==='url') {
$newitems[] = $item;
}
}