Skip to content

Instantly share code, notes, and snippets.

@ahebrank
ahebrank / csv-browse.sh
Created May 21, 2018 14:03
Bash helper to browse a CSV
#!/bin/bash
# requirements:
# - pip3 install datasette csvs-to-sqlite
# - replace "open" below with "sensible-browser", etc., for other OS
if [ $# -lt 1 ]; then
echo "Need one or more csv"
exit 1
fi
@ahebrank
ahebrank / get_dhis2_scripts.sh
Last active June 17, 2018 12:47
Get the DHIS2 visualizer/embed scripts since the CDN no longer works
#!/bin/bash
# destination folder
SCRIPT_DIR=$( pwd )/../assets/js/dhis2
# dhis2 version
VERSION=2.28
# download URL pattern from https://www.dhis2.org/downloads
DOWNLOAD_URL=https://s3-eu-west-1.amazonaws.com/releases.dhis2.org/$VERSION/dhis.war
if [ ! -d $SCRIPT_DIR ]; then
diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
index 705c3e4..8f53737 100644
--- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -30,7 +30,7 @@ class InlineParagraphsWidget extends ParagraphsInlineParagraphsWidget {
*
* @var bool
*/
- private $isTranslating;
+ protected $isTranslating;
diff --git a/src/Element/InlineEntityForm.php b/src/Element/InlineEntityForm.php
index 0fbe233..17bc452 100644
--- a/src/Element/InlineEntityForm.php
+++ b/src/Element/InlineEntityForm.php
@@ -128,9 +128,12 @@ class InlineEntityForm extends RenderElement {
$entity_form['#op'] = $entity_form['#entity']->isNew() ? 'add' : 'edit';
}
}
- // Prepare the entity form and the entity itself for translating.
- $entity_form['#entity'] = TranslationHelper::prepareEntity($entity_form['#entity'], $form_state);
diff --git a/src/Element/InlineEntityForm.php b/src/Element/InlineEntityForm.php
index 0fbe233..f47e2de 100644
--- a/src/Element/InlineEntityForm.php
+++ b/src/Element/InlineEntityForm.php
@@ -8,6 +8,7 @@ use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElement;
use Drupal\inline_entity_form\ElementSubmit;
use Drupal\inline_entity_form\TranslationHelper;
+use Drupal\Core\Entity\ContentEntityInterface;
@ahebrank
ahebrank / update_pathauto_generate_alias.php
Last active June 28, 2018 16:21
Set pathauto state for all entities in a bundle
<?php
// PARAMETER EXAMPLES
// ------------------
// desired status for entities in bundle
// // must be 1 or 0
// $pathauto_status = 1;
// // entity and type
// $entity = 'taxonomy_term';
@ahebrank
ahebrank / check-for-content-entity.patch
Last active July 12, 2018 17:28
Simple entity merge: check for content entity
diff --git a/simple_entity_merge.module b/simple_entity_merge.module
index 277824e..1dae9fb 100644
--- a/simple_entity_merge.module
+++ b/simple_entity_merge.module
@@ -12,6 +12,9 @@ use Drupal\Core\Entity\EntityInterface;
*/
function simple_entity_merge_entity_type_alter(array &$entity_types) {
foreach ($entity_types as $entity_type_id => $entity_type) {
+ if (!$entity_type->isTranslatable()) {
+ continue;
@ahebrank
ahebrank / install_php55_ubuntu.sh
Last active August 9, 2018 19:37 — forked from jniltinho/ install_php55_ubuntu.sh
Install PHP 5.5.38 on Ubuntu 16.04 64Bits
#!/bin/bash
### Install PHP 5.5.38 on Ubuntu 16.04 64Bits
### https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/
apt-get -y install build-essential libxml2-dev libxslt1-dev
apt-get -y install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libxml2-dev
apt-get -y install libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev
apt-get -y install libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev
apt-get -y install libfreetype6-dev libkrb5-dev libpq-dev libicu-dev
@ahebrank
ahebrank / FilterBlankHeadings.php
Last active August 17, 2018 12:26
Drupal 8 text filter plugin to remove blank headings
<?php
namespace Drupal\MY_MODULE\Plugin\Filter;
use Drupal\filter\Plugin\FilterBase;
use Drupal\filter\FilterProcessResult;
/**
* @Filter(
* id = "filter_blank_headings",
@ahebrank
ahebrank / linkit-entity-matcher-sanitizer.patch
Last active August 17, 2018 14:15
Linkit: more specific label sanitization
diff --git a/src/Plugin/Linkit/Matcher/EntityMatcher.php b/src/Plugin/Linkit/Matcher/EntityMatcher.php
index a8a85c8..be57dfa 100644
--- a/src/Plugin/Linkit/Matcher/EntityMatcher.php
+++ b/src/Plugin/Linkit/Matcher/EntityMatcher.php
@@ -3,6 +3,7 @@
namespace Drupal\linkit\Plugin\Linkit\Matcher;
use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\Xss;
use Drupal\Core\Config\Entity\ConfigEntityTypeInterface;