Skip to content

Instantly share code, notes, and snippets.

View amcgowanca's full-sized avatar

Aaron McGowan amcgowanca

View GitHub Profile
@amcgowanca
amcgowanca / imagex_installkit_ops.inc
Last active December 30, 2015 09:09
A rough prototype of an example of how drush can recursively do a git pull on origin remote for the current branch.
<?php
/**
* @file
*/
function imagex_installkit_ops_drush_command() {
$commands = array();
$commands['installkit-ops-update'] = array(
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'aliases' => array('ops-update'),
@amcgowanca
amcgowanca / MODULENAME.module
Created February 4, 2014 14:17
Turn default caching and "use slave" option on for Views 3 in Drupal 7.
/**
* Implements hook_views_default_views_alter().
*/
function MODULENAME_views_default_views_alter(&$views) {
foreach ($views as $view_name => &$view) {
// If the view is disabled, simply continue onto the next.
if (TRUE == $view->disabled) {
continue;
}
@amcgowanca
amcgowanca / test.php
Created June 25, 2014 17:35
PHP's array_key_exists vs. isset
<?php
$array = array(
'a' => 'A',
'b' => 'B',
'c' => 'C',
);
$st = microtime(TRUE);
@amcgowanca
amcgowanca / EntityFieldPropertyQuery.php
Last active August 29, 2015 14:03
Drupal 7 - EntityFieldPropertyQuery class
<?php
/**
* @file
* Contains class EntityFieldPropertyQuery.
*/
/**
* EntityFieldQuery class allowing for base table properties to be returned.
*/
class EntityFieldPropertyQuery extends EntityFieldQuery {
@amcgowanca
amcgowanca / MODULENAME.install
Last active August 29, 2015 14:03
Views Argument Cache with Indexing: Update argument index table `aid` length
<?php
/**
* @file
*/
/**
* Implements hook_schema_alter().
*/
function MODULENAME_schema_alter(&$schema) {
if (isset($schema['views_arg_cache_index_arguments'])) {
@amcgowanca
amcgowanca / github-pull-request-template.md
Last active August 18, 2016 21:53
Pull Request Template

Ready State: Yes|No

This pull request is related to the following JIRA tickets: XYZ-1: Sample Ticket A.

Requirements & Dependencies

  • This new module requires version xyz of module.
  • Requires pull request #148.

Deployment Instructions

<?php
/**
* Returns the node identifier should the path be a node viewing path.
*
* Note: This function returns FALSE for all node action or local task paths
* such as node/[nid]/edit.
*
* Furthermore, a node alias may be specified as $path which will perform a path
* normalization allowing for the node system path to be retrieved and parsed.
*

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@amcgowanca
amcgowanca / patch.patch
Created February 19, 2015 01:36
Drupal 7: Patch for panelizer for menu links "disappearing"
diff --git a/plugins/entity/PanelizerEntityNode.class.php b/plugins/entity/PanelizerEntityNode.class.php
index 5ea50a1..14027ce 100644
--- a/plugins/entity/PanelizerEntityNode.class.php
+++ b/plugins/entity/PanelizerEntityNode.class.php
@@ -32,6 +32,9 @@ class PanelizerEntityNode extends PanelizerEntityDefault {
if (isset($entity->workbench_moderation)) {
$entity->workbench_moderation['updating_live_revision'] = TRUE;
}
+ if (!empty($entity->menu['link_title'])) {
+ $entity->menu['enabled'] = TRUE;
@amcgowanca
amcgowanca / MY_MODULE.module
Created February 19, 2015 18:19
Drupal 7: Path argument mapping to $form_state['values'] default
<?php
/**
* Retrieves a single form by the $form_id and maps path arguments to values.
*
* This function mimics the behaviour of drupal_get_form() however it also
* provides a mechanism to map path arguments to the default values provided
* to the form via $form_state['values']. This solves a massive problem with
* the Drupal core ability to correctly handle forms with that have methods of
* type "GET" (<form method="get">) correctly.