Skip to content

Instantly share code, notes, and snippets.

@woombo
woombo / Enforce array on an object
Created April 10, 2015 20:16
Enforce array on an object
<?php
// Enforce all rows are converted to an array when needed.
$rows = json_decode(json_encode($endpoints), TRUE);
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc
@woombo
woombo / gist:254e0a6f188236fccd7f
Created June 5, 2015 18:47
Drupal Features: Allow custom view templates to be placed within feature
<?php
/**
* Implements hook_views_api_alter().
* Alter the list of modules/themes which implement a views api.
*/
function MODULE_views_api_alter(&$list) {
// Alter the path of the views implementation.
if (isset($list['MODULE'])) {
$path = drupal_get_path('module', 'MODULE');
$list['MODULE']['path'] = $path;
@woombo
woombo / xdebug
Created July 15, 2015 22:04
xdebug
xdebug.max_nesting_level=256
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
;xdebug.profiler_enable=0
;xdebug.profiler_output_dir="/Applications/MAMP/tmp"
zend_extension="/Applications/MAMP/bin/php/php5.5.17/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
@woombo
woombo / drupal_content_type_to_taxonomy.php
Created July 27, 2015 17:15
Creates taxonomy every time a content type is saved.
<?php
/*
* Implements hook_node_update().
*/
function openedu_school_node_update($node) {
if ($node->type == 'school' && isset($node->field_school_category['und'][0]['tid'])) {
$term = taxonomy_term_load($node->field_school_category['und'][0]['tid']);
$term->name = $node->title; //change existed taxonomy term
taxonomy_term_save($term);
@woombo
woombo / hook_inline_entity_form_table_fields_alter.module
Last active February 11, 2016 18:12
hook_inline_entity_form_table_fields_alter()
/**
* Implements hook_inline_entity_form_table_fields_alter().
*/
function MODULE_inline_entity_form_table_fields_alter(&$fields, $context) {
if ($context['parent_bundle'] === 'MODULE' &&
$context['entity_type'] === 'MODULE_text_asset') {
// Remove Title.
unset($fields['id']);
@woombo
woombo / plugin-class-demo.php
Created November 2, 2016 10:57 — forked from thefuxia/plugin-class-demo.php
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: GPL
* Text Domain: plugin_unique_name
@woombo
woombo / __INDEX.txt
Created December 22, 2016 11:37 — forked from facine/__INDEX.txt
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes: