Skip to content

Instantly share code, notes, and snippets.

@szeidler
szeidler / start-selenium-chrome-node-d4d.sh
Last active February 20, 2018 09:47
Start selenium chrome node with Docker4Drupal
#!/bin/sh
selenium-server -role node -hub http://localhost:4444/grid/register
@szeidler
szeidler / docker-compose.yml
Created February 11, 2018 10:09
PhantomJS on Docker4Drupal
phantomjs:
image: wernight/phantomjs:2
volumes_from:
- php
links:
- nginx
entrypoint: phantomjs
command: "--ssl-protocol=any --ignore-ssl-errors=true /var/www/html/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768"
@szeidler
szeidler / contenta_jsonapi-json_render_only_full_view_mode.patch
Last active December 28, 2017 09:57
Show JSON API representation of node only on default and full view mode
diff --git a/modules/contenta_enhancements/contenta_enhancements.module b/modules/contenta_enhancements/contenta_enhancements.module
index d1b9951..8f0364b 100644
--- a/modules/contenta_enhancements/contenta_enhancements.module
+++ b/modules/contenta_enhancements/contenta_enhancements.module
@@ -362,7 +362,7 @@ function contenta_enhancements_toolbar_alter(&$items) {
function contenta_enhancements_node_view_alter(array &$build, NodeInterface $entity, EntityViewDisplayInterface $display) {
// Make sure the help pages are left alone.
// TODO: Use the concept of view modes to solve this problem, not this hack.
- if ($entity->bundle() === 'page') {
+ if ($entity->bundle() === 'page' || ($display->getMode() !== 'default' && $display->getMode() !== 'full')) {
@szeidler
szeidler / simplesamlphp.conf
Created November 28, 2017 15:10
SimpleSAMLphp Nginx Docker4Drupal configuration
location ^~ /simplesaml {
alias /var/www/html/web/simplesaml;
location ~ ^(?<prefix>/simplesaml)(?<phpfile>.+?\.php)(?<pathinfo>/.*)?$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$phpfile;
fastcgi_param PATH_INFO $pathinfo if_not_empty;
}
}
@szeidler
szeidler / term_merge-prevent_duplicate_references-2924108-2.patch
Created November 16, 2017 17:34
Prevent references fields from creating duplicates
diff --git a/src/TermMerger.php b/src/TermMerger.php
index 2b341f6..d96ae0d 100644
--- a/src/TermMerger.php
+++ b/src/TermMerger.php
@@ -177,13 +177,30 @@ class TermMerger implements TermMergerInterface {
}
$referenceUpdated = FALSE;
- foreach ($values as &$value) {
+ $targetTermExists = FALSE;
@szeidler
szeidler / fotoweb-write-back-metadata.php
Created October 19, 2017 12:01
Writeback metadata using the FotowebSteamWrapper
if ($file_wrapper = file_stream_wrapper_get_instance_by_uri($file->uri)) {
// Specifiy the Fotoweb property to update.
$metadata_key_to_update = 60;
// Set the new value.
$file->metadata['asset_metadata'][$metadata_key_to_update]['value'] = 'My new caption';
// Update the metadata and trigger the file_save, which could
// overwrite the $file->metadata with the actual asset metadata
// for data consistency.
@szeidler
szeidler / merge-fotoweb-metadata-into-file-entity-fields.php
Created October 19, 2017 11:50
Merge Fotoweb metadata into File Entity fields
<?php
function mymodule_file_presave($file) {
if ($file->type === 'image' && file_uri_scheme($file->uri) === 'fotoweb') {
$wrapper = entity_metadata_wrapper('file', $file);
$field_map = array(
'field_file_image_alt_text' => 120,
'field_file_image_title_text' => 5,
'field_image_caption' => 121,
'field_image_byline' => 80,
@szeidler
szeidler / update-d4d-images.sh
Last active August 27, 2017 15:34
Update docker4drupal images to recent version - recursive.
#!/bin/bash
# Update PHP 7.0
find . -maxdepth 2 -name "docker-compose.yml" -exec sed -i '' 's#wodby/drupal-php:7.0-[0-9].[0-9].[0-9]#wodby/drupal-php:7.0-2.4.6#g' '{}' \;
# Update PHP 7.1
find . -maxdepth 2 -name "docker-compose.yml" -exec sed -i '' 's#wodby/drupal-php:7.1-[0-9].[0-9].[0-9]#wodby/drupal-php:7.1-2.4.6#g' '{}' \;
# Update MariaDB
find . -maxdepth 2 -name "docker-compose.yml" -exec sed -i '' 's#wodby/mariadb:10.1-[0-9].[0-9].[0-9]#wodby/mariadb:10.1-2.3.4#g' '{}' \;
@szeidler
szeidler / d4d-add-developer-tools.sh
Last active August 8, 2017 16:38
Add developer tools to docker4drupal (Drush Pachfile, Registry Rebuild)
#!/bin/bash
# Remove and reinstall drush patchfile.
docker-compose exec --user root php sh -c 'if [ -d "/home/www-data/.drush/drush-patchfile" ]; then rm -rf /home/www-data/.drush/drush-patchfile; fi;'
docker-compose exec --user 82 php sh -c 'git clone https://[email protected]/szeidler/drush-patchfile.git /home/www-data/.drush/drush-patchfile'
# Remove and reinstall registry rebuild.
docker-compose exec --user root php sh -c 'if [ -d "/home/www-data/.drush/registry_rebuild" ]; then rm -rf /home/www-data/.drush/registry_rebuild; fi;'
docker-compose exec --user 82 php drush @none dl registry_rebuild-7.x
@szeidler
szeidler / easy-drush-file-rsync.sh
Created July 25, 2017 11:05
Easy drush file rsync
drush rsync @source_alias:%files @target_alias:%files --dry-run --ignore-existing --progress