This file contains hidden or 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
class @Waiter | |
waitAndReturn: (success) -> | |
setTimeout(success, 1000) |
This file contains hidden or 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
QUnit.module 'Waiter class' | |
test 'Waiter waits for 1 seconds', (assert) -> | |
done = do assert.async | |
waiter = new Waiter() | |
waiter.waitAndReturn -> | |
ok true, 'Timer completed' | |
do done |
This file contains hidden or 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
QUnit.module 'Waiter class' | |
test 'Waiter waits for 1 second twice', (assert) -> | |
done1 = do assert.async | |
done2 = do assert.async | |
assert.expect 2 | |
waiter = new Waiter() | |
This file contains hidden or 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 | |
// Add some data to the current user. | |
global $user; | |
$user->data['foo'] = 'bar'; | |
user_save($user); | |
// Access some data from the current user. | |
global $user; | |
$user_data = $user->data['foo']; |
This file contains hidden or 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 | |
$user->data['employee'] = array( | |
'employee_number' => 123456, | |
'employee_details' => array( | |
'salary' => 65000, | |
'access_level' => 'A', | |
'start_date' => 1425439660, | |
), | |
); | |
user_save($user); |
This file contains hidden or 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 | |
// Set the employee salary of a user. | |
$account = user_load(1); | |
$employee_details = new EmployeeDetails($account); | |
$employee_details->setEmployeeSalary(65000); | |
user_save($account); | |
// Retrieve the employee salary for a given user. | |
$account = user_load(1); | |
$employee_details = new EmployeeDetails($account); |
This file contains hidden or 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 | |
class EmployeeDetails { | |
/** | |
* The associated user account. | |
*/ | |
protected $account; | |
/** | |
* The key for accessing data. | |
*/ |
This file contains hidden or 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 | |
global $user; | |
$account = entity_metadata_wrapper('user', $user); | |
$account->employee_number->set(60000); | |
entity_save('user', $account); | |
$employee_number = $account->employee_number->value(); |
This file contains hidden or 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 | |
/** | |
* Implements hook_entity_property_info_alter(). | |
*/ | |
function my_custom_module_entity_property_info_alter(&$info) { | |
$properties = &$info['user']['properties']; | |
$properties['employee_number'] = array( | |
'label' => t("Employee number"), | |
'description' => t("The employee number of this user."), |
This file contains hidden or 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
drush sql-query "UPDATE system SET schema_version = 7001 WHERE name = 'my_custom_module';" |