Skip to content

Instantly share code, notes, and snippets.

@aczietlow
aczietlow / phpcs-cleanup.sh
Created August 15, 2017 16:02
Docksal command that runs phpcbf against the project's code base.
#!/usr/bin/env bash
## Runs phpcbf to clean up code-sniffer errors.
## In composer.json:
## "require": {
## . "drupal/coder": "^8.2"
## }
@aczietlow
aczietlow / fix-docksal.sh
Last active August 9, 2017 00:46
Remove all things docksal and revert back to the 1.3 release... Better times.
#!/usr/bin/env sh
export DOCKSAL_VERSION=v1.3.1
docker_config="$HOME/.docker"
docksal_config="$HOME/.docksal"
echo "Removing the VM just to be sure"
fin vm remove
if [ -d "$docker_config" ]; then
#!/usr/bin/env bash
## Creates a new docker database image using the backup of the live environment.
##
## Usage: fin update-database-image
# Abort if anything fails
set -e
SITE_DIRECTORY="default"

Drupal GovCon 2017

Docker & Kubernetes

WTF is kubernetes?

  • monitors containers
  • Deployment of containers
  • Handles communication b/n containers

Kubernetes could be used to use docksal to manage Production level hosting

@aczietlow
aczietlow / quick_field_save.php
Last active July 28, 2017 16:20
Faster way of updating single field of an entity
<?php
function updateProductCategoryReference($product_id, $new_cat_tid) {
$product = new stdClass();
$product->product_id = $product_id;
$product->type = 'product';
$product->field_product_category[LANGUAGE_NONE][]['tid'] = $new_cat_tid;
$transaction = db_transaction();
try {
field_attach_presave('commerce_product', $product);
field_attach_update('commerce_product', $product);
<?php
$domains = [
0 => [
'domain_id' => 7,
],
1 => [
'domain_id' => 7,
],
2 => [
'domain_id' => 7,
███ OS & BASICS
Darwin vulcan 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Mac OS X 10.12.4
fin version: 1.10.0
Mode: VirtualBox VM
███ INSTANCES
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
docksal * virtualbox Running tcp://192.168.64.100:2376 v17.04.0-ce
███ DOCKER
DOCKER_HOST: tcp://192.168.64.100:2376
@aczietlow
aczietlow / rebuild
Last active May 2, 2017 18:39
Docksal command to work with Pantheon
#!/usr/bin/env bash
# Abort if anything fails
set -e
SITE_DIRECTORY="default"
DOCROOT_PATH="${PROJECT_ROOT}/${DOCROOT}"
SITEDIR_PATH="${DOCROOT_PATH}/sites/${SITE_DIRECTORY}"
ARTIFACT_PATH="${PROJECT_ROOT}/artifacts"
<?php
$form[$bundle . '_fieldset']['markup'] = [
'#title' => t("Generated Markup"),
'#prefix' => '<xmp id="snippet-container">',
'#markup' => _my_custom_module_get_markup($bundle),
'#suffix' => '</xmp>',
];