Skip to content

Instantly share code, notes, and snippets.

@sonnykt
sonnykt / dump_route53_records.md
Created December 5, 2018 00:14 — forked from porjo/dump_route53_records.md
Export route53 records to CSV

Retrieve hosted zones with aws route53 list-hosted-zones then enter the zone Id below:

aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/xxxxxxxxxxx" | \
   jq -r '.ResourceRecordSets[] | [.Name, .Type, (.ResourceRecords[]? | .Value), .AliasTarget.DNSName?]  | @tsv'
@sonnykt
sonnykt / drupal8-module-vs-theme.md
Last active May 21, 2021 02:51
Drupal 8 - module vs theme

Alter hooks

In 7.x, themes were allowed to participate in any alter hook because the code that invoked theme alters lived in drupal_alter(). In 8.x, there has been a clear and distinct separation between ModuleHandler::alter and ThemeManager::alter. So now, in 8.x, themes can only participate in an alter hook if it is explicitly invoked for themes as well. An example of this can be seen in ElementInfoManager::buildInfo:

$this->moduleHandler->alter('element_info', $info);
$this->themeManager->alter('element_info', $info);

As far as a "list" of what alter hooks themes are allowed to participate in... I really don't know of any. This base theme implements the majority/common alters hooks found in themes and you can see what it implements in bootstrap.theme. The only other suggestion I would have towards this subject is to see what code implements the module alter and see if there's a theme alter along with it.

Services/container

@sonnykt
sonnykt / drupal-10-decode-css-js-aggr-include.md
Last active July 26, 2024 03:36
Drupal 10 - decode CSS/JS aggregated include string
use Drupal\Component\Utility\UrlHelper;

$include = 'eJx...';
explode(',',UrlHelper::uncompressQueryParameter($include));
@sonnykt
sonnykt / drupal-10-debug-elasticsearch-connector.md
Created July 26, 2024 03:39
Drupal 10 - debug Elasticsearch connector
use Drupal\search_api\Entity\Index;

$index = Index::load('node')
$server = $index->getServerInstance()
$backend = $server->getBackend()
$backend->getCluster()

$cluster_manager = \Drupal::service('elasticsearch_connector.cluster_manager')
@sonnykt
sonnykt / drupal-check-node-view-display-with-panelizer.md
Last active August 29, 2024 03:37
Drupal 10 - Check node view displays using Panelizer
use \Drupal\node\Entity\NodeType;

$panelizer = [];
$repo = \Drupal::service('entity_display.repository');

$types = NodeType::loadMultiple();
foreach (array_keys($types) as $node_type) {
  $viewmode_options = $repo->getViewModeOptionsByBundle('node', $node_type);
 foreach (array_keys($viewmode_options) as $viewmode_option) {
@sonnykt
sonnykt / drupal-sdp-debug-bay-elasticsearch.md
Last active August 30, 2024 10:53
Drupal - SDP - Debug Bay Elasticsearch from the CLI container

Get indices

curl -sXGET  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_cat/indices?format=json&pretty=true"

curl -sXGET  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_cat/indices/${SEARCH_HASH}--${SEARCH_INDEX}node?format=json&pretty=true"

Get ingest pipelines

curl -s  "http://${SEARCH_AUTH_USERNAME}:${SEARCH_AUTH_PASSWORD}@${SEARCH_HASH}.${SEARCH_URL}/_ingest/pipeline?pretty=true"
@sonnykt
sonnykt / drupal-migrate-plus-simulate-http-fetcher-plugin.md
Last active September 5, 2024 04:54
Drupal 10 - Migration - Simulate migrate_plus HTTP fetcher plugin
$entity_type_manager = \Drupal::entityTypeManager();
$storage = $entity_type_manager->getStorage('migration');
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');

$migration_id = '...';
$migration = $storage->load($migration_id);
$migration_plugin = $migration_plugin_manager->createInstance($migration_id, $migration->toArray());

$source_plugin = $migration_plugin->getSourcePlugin();
@sonnykt
sonnykt / drupal-mysql-convert-collation-all-tables.md
Last active October 17, 2024 02:04
Drupal 10 - Convert collation of all tables
$database = \Drupal::database();
$charset = $database->getConnectionOptions()['charset'] ?? 'utf8mb4';
$collation = $database->getConnectionOptions()['collation'] ?? 'utf8mb4_general_ci';

echo PHP_EOL;

$tables = $database->query('SHOW TABLE STATUS where Collation <> :collation', [':collation' => $collation ])->fetchAllAssoc('Name');
if (count($tables)) {
  echo 'Converting collation of ', count($tables), ' tables to ', $collation, PHP_EOL;