admin's blog

Returns a map of field names and vocabularies they can reference

function _get_tax_term_fields_map() {
  static $map;
  if (isset($map)) {
    return $map;

  // First, find all taxonomy term fields.
  foreach (field_info_fields() as $field) {
    if ('taxonomy_term_reference' === $field['type']) {
      $all[] = $field;

  // Next, build a map, keyed by the field name.
  foreach ($all as $field) {
    foreach ($field['settings']['allowed_values'] as $vocab_info) {

Loop through a wrapper entity's properties

function _wrapper_debug($w) {
  $values = array();
  foreach ($w->getPropertyInfo() as $key => $val) {
    $values[$key] = $w->$key->value();
  return $values;


Set up xdebug with Vagrant

1. Find out what the IP address of gateway is with “route -n”
2. Edit xdebug.ini at /etc/php5/conf.d

GZIP with tar command

Creating an archive using tar command

Creating an uncompressed tar archive using option cvf
This is the basic command to create a tar archive.

$ tar cvf archive_name.tar dirname/
In the above command:

c – create a new archive
v – verbosely list files which are processed.
f – following is the archive file name
Creating a tar gzipped archive using option cvzf
The above tar cvf option, does not provide any compression. To use a gzip compression on the tar archive, use the z option as shown below.

Printing to terminal with drush

foreach(debug_backtrace() as $item) {
  if ($item['function'] == 'webwise_eck_contact_field_extra_fields') {


Subscribe to RSS - admin's blog