Skip to content

Instantly share code, notes, and snippets.

@simesy
simesy / gist:b23f3720d1d845c314a5d1efa76aed26
Created November 19, 2019 06:45
Re-save redirects if manipulating redirect table directly
# If the values change the hash needs to be fixed.
drush eval '$r=\Drupal::entityQuery("redirect")->execute(); $x=\Drupal\redirect\Entity\Redirect::loadMultiple($r); foreach($x as $y) { $y->save(); }'
@simesy
simesy / gist:d4dec3d04ef6909b97a496be4d71182f
Created November 15, 2019 06:40
Quick table rows with drush
for t in $(drush sqlq "show tables"); do echo $(drush sqlq "SELECT '$t' n, COUNT(*) r FROM $t") ; done
@simesy
simesy / docker-compose.override.yml
Created November 13, 2019 06:15
Mount custom/modules for local development.
version: '2.3'
services:
cli:
volumes:
- ./custom/modules:/app/web/sites/default/modules/local:${VOLUME_FLAGS:-delegated}
test:
volumes:
- ./custom/modules:/app/web/sites/default/modules/local:${VOLUME_FLAGS:-delegated}
@simesy
simesy / nofile.txt
Last active April 20, 2025 05:44
GovCMS dev tooling check
# You can copy/paste this command into your terminal.
echo "Check your GovCMS developer tools:" \
&& git --version \
&& docker --version \
&& docker-compose --version \
&& pygmy --version \
&& echo "Ahoy "$(ahoy --version)
@simesy
simesy / README.txt
Last active April 24, 2019 04:13
Drupal 8 - Example settings.php setup
See https://lilengine.co/articles/example-settings-php-drupal-8
File structure in sites/default/...
- settings.php
- includes/
--- default.settings.php
--- default.services.yml
--- lando.settings.php
--- lando.services.yml
#!/usr/bin/env bash
# Pushed into the container by .lando.yml
alias phpunit=/app/vendor/bin/phpunit
@simesy
simesy / gist:f667eab8eb180bc5bbeb319c4a7930ea
Created August 26, 2018 12:18
Debugging some proxy things
<?php
print "\n\nSERVER HEADERS:\n\n";
print(var_export($_SERVER, TRUE));
print "\n\nSymfony HTTP Foundation request headers:\n\n";
$request = \Drupal::request();
foreach ($request->headers->all() as $key => $header) {
print $key . ': ' . $header[0] . "\n";
}
@simesy
simesy / AliasedLinkEnhancer.php
Created June 6, 2018 10:30
Rosolve internal links - change MYMODULE and put in src/Plugin/jsonapi/FieldEnhancer
<?php
namespace Drupal\MYMODULE\Plugin\jsonapi\FieldEnhancer;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase;
use Shaper\Util\Context;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Url;
@simesy
simesy / EntityType.php
Created May 15, 2018 21:16
Search api processor plugin to add entity type as an indexed field.
<?php
namespace Drupal\PROJECT\Plugin\search_api\processor;
use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;
/**
@simesy
simesy / JsonapiData.php
Last active May 14, 2018 23:19
Offers a new "JSON Data" field when you "Add fields" in the Drupal search_api interface. If you set the field to "Full text" it will be searchable.
<?php
namespace Drupal\PROJECT\Plugin\search_api\processor;
use Drupal\search_api\Datasource\DatasourceInterface;
use Drupal\search_api\Item\ItemInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Processor\ProcessorProperty;
/**