Last active
May 24, 2016 08:08
-
-
Save jakelacey2012/730b746c4e74016ac013a1417a3e0708 to your computer and use it in GitHub Desktop.
Decouple DEBUGGING!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* updateds nodes helper debug function this is where all our debug code can go | |
* @param [array] $debug Avaliable debug information pass more for more to become | |
* @param [boolean] $die This will break on the first interation | |
* @param [array] $array An array containing all of the values that have been | |
* passed in one build. | |
* avaliable.! | |
*/ | |
function decouple_debug($debug = array(), $die = false, &$build = array()) { | |
// if true break | |
if ($die == true) { | |
krumo($debug); die; | |
} | |
// watchdog out the debug information change as an when | |
watchdog( | |
'aw_booking_price_de', | |
' | |
Node ID: %id - | |
Check 1st: %first_check - | |
Check 2st: %second_check - | |
Sell Price: %sell_price - | |
Price: %price - | |
Form Price: %form_price - | |
CG Price: %cg_price - | |
Form Cert Price: %form_cert_price - | |
Changed: %changed | |
', $debug , WATCHDOG_NOTICE, $link = NULL); | |
// add debug information onto build | |
$build[] = $debug; | |
} | |
/** | |
* An example function for using the decouple debugger. | |
*/ | |
function decouple_debugging_example() { | |
// debug information | |
decouple_debug(array( | |
'%id' => $entity->nid, | |
'%first_check' => ((number_format($entity->sell_price, 2) !== number_format($price, 2)) || (number_format($entity->price, 2) !== number_format($price, 2))), | |
'%second_check' => (number_format($entity->field_price_cgprice['und'][0]['value'], 2) !== number_format($certPrice, 2)), | |
'%sell_price' => number_format($entity->sell_price, 2), | |
'%price' => number_format($entity->price, 2), | |
'%form_price' => number_format($price, 2), | |
'%cg_price' => number_format($entity->field_price_cgprice['und'][0]['value'], 2), | |
'%form_cert_price' => number_format($certPrice, 2), | |
'%changed' => number_format($changed) | |
), false, $debug); | |
krumo($debug); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment