Skip to content

Instantly share code, notes, and snippets.

View filiphazardous's full-sized avatar

Filip Joelsson filiphazardous

View GitHub Profile
diff -ru a/src/Normalizer/FileEntityNormalizer.php b/file_entity/src/Normalizer/FileEntityNormalizer.php
--- a/src/Normalizer/FileEntityNormalizer.php
+++ b/src/Normalizer/FileEntityNormalizer.php
@@ -48,6 +48,7 @@
else {
throw new \RuntimeException(SafeMarkup::format('Failed to write @filename.', array('@filename' => $entity->getFilename())));
}
+ $entity->status = FILE_STATUS_PERMANENT;
return $entity;
}
@filiphazardous
filiphazardous / viewsreference_add_entity_to_context.patch
Last active March 29, 2018 08:11
Add nodes in block to context for viewsreference
diff -ru a/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php b/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
--- a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
@@ -100,6 +100,9 @@
}
$node = \Drupal::routeMatch()->getParameter('node');
+ if (!$node && $items->getEntity() instanceof \Drupal\node\NodeInterface) {
+ $node = $items->getEntity();
+ }
@filiphazardous
filiphazardous / viewsreference_add_entity_to_context-2.patch
Created March 29, 2018 08:13
Add nodes in block to context for viewsreference v2
diff -ru a/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php b/viewsreference/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
--- a/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/ViewsReferenceFieldFormatter.php
@@ -100,6 +100,9 @@
}
$node = \Drupal::routeMatch()->getParameter('node');
+ if ($items->getEntity() instanceof \Drupal\node\NodeInterface) {
+ $node = $items->getEntity();
+ }
@filiphazardous
filiphazardous / user-revision-d9-compat.patch
Last active November 15, 2021 09:23
Patch to bring the user_revision up to D9 compatibility
diff --git a/src/Form/UserRevisionDeleteForm.php b/src/Form/UserRevisionDeleteForm.php
index cb7f0ce..3d3237f 100644
--- a/src/Form/UserRevisionDeleteForm.php
+++ b/src/Form/UserRevisionDeleteForm.php
@@ -42,7 +42,7 @@ class UserRevisionDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- $entity_manager = $container->get('entity.manager');
+ $entity_manager = $container->get('entity_type.manager');
@filiphazardous
filiphazardous / safe_print_r.php
Created March 25, 2022 09:56
Limited recursion print_r re-implementation
<?php
/**
* Useful util func for debugging PHP. When var_dump and print_r blows the stack, I use this instead.
* Eg: die("<pre>".preg_replace("/</", "&lt;", safe_print_r($my_bloated_circular_object))."</pre>");
* Heavily inspired by the comments on: https://www.php.net/manual/en/function.print-r.php
*/
function safe_print_r($data, $nesting = 6, $indent = '')
{
$in = ' ';
if (!is_object($data) && !is_array($data)) {