Skip to content

Instantly share code, notes, and snippets.

View dpi's full-sized avatar

dpi dpi

View GitHub Profile
<?php
/**
* @file
* Dumping ground for stubs, until a pattern emerges.
*/
declare(strict_types=1);
namespace Drupal\datetime\Plugin\Field\FieldType {
@dpi
dpi / Drupal revision_translation_affected.md
Created March 15, 2019 09:21
revision_translation_affected for test entities

Getting issues like?

Drupal\Core\Entity\Query\QueryException: 'revision_translation_affected' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 351 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).
Drupal\Core\Entity\Query\Sql\Tables->addField('revision_translation_affected', 'INNER', 'en') (Line: 52)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 172)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 80)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 433)
Drupal\Core\Entity\ContentEntityStorageBase->getLatestTranslationAffectedRevisionId('1', 'en') (Line: 157)
Drupal\content_moderation\ModerationInformation-&gt;hasPendingRevision(Object) (Line: 58)
@dpi
dpi / jobitem.php
Last active April 15, 2016 13:19
notifyNeedsReview redux
/**
* Notify the owner of the Job using courier.
*/
private function notifyNeedsReview() {
$template_collection_ids = \Drupal::state()->get('tmgmt_notifications_template_collections', []);
if (isset($template_collection_ids['job_item_needs_review'])) {
$id = $template_collection_ids['job_item_needs_review'];
/** @var \Drupal\courier\TemplateCollectionInterface $template_collection */
@dpi
dpi / registrants.php
Last active August 29, 2015 14:26
Registrants for an event via API (https://github.com/dpi/rng)
$event = entity_load( your event entity here )
$event_manager = \Drupal::service('rng.event_manager');
$event_meta = $event_manager->getMeta($event);
foreach ($event_meta->getRegistrations() as $registration) {
foreach ($registration->getRegistrants() as $registrant) {
$registrant->label();
$registrant->id();
}
}
@dpi
dpi / gist:1079482
Created July 13, 2011 00:14
Drupal Relation/References Widgets
<letharion> chx: Do you already have any thoughts on whether and how to provide a references-style field widget for nodes?
<chx> letharion: no
<chx> letharion: we will reuse the references widgets instead.
<letharion> chx: Great. Have you talked to the maintainers? Do we intend to copy their widgets into the relation codebase?
<chx> copy?
<chx> heaven forbid
<chx> this is field API
<chx> we just need to make a field type
<chx> and then alter widget info to get em in the house.
<letharion> chx: I'm not sure I follow, will references then depend on relation?