Skip to content

Instantly share code, notes, and snippets.

View lhuria94's full-sized avatar
🏠
Working from home

Love Huria lhuria94

🏠
Working from home
View GitHub Profile
@lhuria94
lhuria94 / git-restore-file.sh
Created September 22, 2017 06:08 — forked from msankhala/git-restore-file.sh
Find and restore a deleted file in a Git
# Find last commit for the deleted file
git rev-list -n 1 HEAD -- $path
# Checkout the commit before the the delete happened
git checkout $commit^ -- $path
@lhuria94
lhuria94 / entity-metadata-wrapper-isset.php
Created February 17, 2017 06:11 — forked from msankhala/entity-metadata-wrapper-isset.php
entity-metadata-wrapper isset check.
<?php
$field_collection_item = field_collection_item_load($id);
$item_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);
// this results in an error if the field_contrib_headshot field is empty
$headshot = $item_wrapper->field_contributor->field_contrib_headshot->value();
Solution:
// EntityStructureWrapper implements the __isset() function according the principe of Overloading.
$headshot = array();