Skip to content

Instantly share code, notes, and snippets.

View a-fro's full-sized avatar

Aaron Froehlich a-fro

  • Cornell University
  • Ithaca, NY
View GitHub Profile
<?php
namespace Drupal\field_layout\Form;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Implements hook_form_alter().
*/
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'submenu_reorder_node_page_reorder') {
foreach (element_children($form['menu_items']) as $id) {
$menu_link = menu_link_load($id);
$url = url($menu_link["link_path"]);
$form['menu_items'][$id]['link_title']['#markup'] = '<a href="'. $url .'">'. $menu_link["link_title"] . '</a>';
}
@a-fro
a-fro / DrupalVM3.0.md
Last active May 27, 2016 13:53
Notes on upgrading to the latest/greatest DrupalVM for ILR

Upgrading to DrupalVM 3.0 with PHP 7.0

  1. If you are in the middle of some work, feel free to create a backup of your current database, either with SequelPro, or via

    drush cc all
    drush sql-dump -l default --gzip --result-file=../db/backups/pre-vm-upgrade-$(date +%m.%d.%y-%H-%M).sql.gzip
    
  2. Remove the current environment with vagrant destroy -f

@a-fro
a-fro / post-checkout
Created April 24, 2015 18:49
post-checkout
#! /bin/sh
# Start from the repository root.
cd ./$(git rev-parse --show-cdup)
compass compile
@a-fro
a-fro / post-merge
Last active August 29, 2015 14:19
git post-merge hook to get compiled CSS to Acquia
#! /bin/sh
BRANCH_NAME="$(git symbolic-ref HEAD 2>/dev/null)" ||
BRANCH_NAME="detached"
BRANCH_NAME=${BRANCH_NAME##refs/heads/}
if [ "$BRANCH_NAME" = "production" ]; then
compass compile
git add docroot/sites/all/themes/ilr_theme/css/ -f
git diff --cached --exit-code > /dev/null
<?php
/**
* Implements hook_node_view().
*/
function tweet_this_node_view($node, $view_mode, $langcode) {
if ($view_mode == "full" && $node->type == "article") {
_tweet_this_generate_button($node);
}
@a-fro
a-fro / tasks.yml
Created October 27, 2014 12:36
pre-task/role/task example
---
- hosts: all
gather_facts: yes
vars_files:
- vars/main.yml
pre_tasks:
- include: tasks/init.yml
@a-fro
a-fro / deploy.sh
Created October 23, 2014 14:34
Acquia Deploy script
#!/bin/bash
REPO_BASE='[project foldername here (the folder above docroot)]'
# check running from the repository base
CURRENT_DIR=${PWD##*/}
if [ ! "$CURRENT_DIR" = $REPO_BASE ]; then
echo 'Please be sure that you are running this command from the root of the repo.'
exit 2
fi
@a-fro
a-fro / main.yml
Last active August 29, 2015 14:07
Var file
drupal_domain: "a-fro.dev"
drupal_core_path: "/var/www/{{ drupal_domain }}/docroot"
drupal_repo_url: "git@github.com:a-fro/a-fro.com.git"
drupal_site_name: "Aaron Froehlich's Blog"
drupal_mysql_user: drupal
drupal_mysql_password: password
drupal_mysql_database: dbname
drupal_admin: admin
drupal_admin_password: password
drupal_theme_path: "{{ drupal_core_path }}/themes/afro"
@a-fro
a-fro / Drupal.yml
Last active August 29, 2015 14:07
Drupal task
---
- name: Create Drupal database.
mysql_db: >
db={{ drupal_mysql_database }}
state=present
- name: Create a MySQL user for Drupal.
mysql_user: >
name={{ drupal_mysql_user }}
host={{ item }}