Skip to content

Instantly share code, notes, and snippets.

View acbramley's full-sized avatar

Adam Bramley acbramley

  • PreviousNext
  • Melbourne, Australia
View GitHub Profile
@acbramley
acbramley / SomeModuleHooks.php
Created June 9, 2023 01:11
Update child aliases Entity Hierarchy
<?php
declare(strict_types = 1);
namespace Drupal\some_module\Hooks;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\entity_hierarchy\Storage\EntityTreeNodeMapperInterface;
use Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory;
use Drupal\entity_hierarchy\Storage\NestedSetStorageFactory;
@acbramley
acbramley / EventSubscriber.php
Created June 1, 2020 02:36
Limit bundles in jsonapi
<?php
namespace Drupal\my_module\EventSubscriber;
use Drupal\jsonapi\ResourceType\ResourceTypeBuildEvents;
use Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Event subscriber to disable all resource types except what we need.
@acbramley
acbramley / report.php
Last active May 6, 2020 01:12
CSV Report of Nodes from a given time with published on dates
<?php
use League\Csv\Writer;
$entityStorage = \Drupal::entityTypeManager()->getStorage('node');
$entityTypeStorage = \Drupal::entityTypeManager()->getStorage('node_type');
$db = \Drupal::database();
$nids = $entityStorage->getQuery()
// Everything since Jan 1st 2020
->condition('created', '1577836800', '>=')
<?php
namespace Drupal\tfnsw_corp_asa_standard\Plugin\Field\FieldWidget;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget;
use Drupal\Core\Form\FormStateInterface;
/**
<?php
namespace Drupal\djr_views\Plugin\views\filter;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid;
use Drupal\views\Plugin\views\filter\InOperator;
/**