-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommerce_drush.module
33 lines (27 loc) · 1.01 KB
/
commerce_drush.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* @file
* Defines the Commerce drush commands to manage orders and interact with them.
*/
/**
* Implements hook_user_insert().
*/
function commerce_drush_entity_presave($entity, $type) {
// We need to ensure that generated data aren't too long.
if ($type === 'user') {
if (isset($entity->devel_generate)) {
// We don't want default.invalid host, we want example.com - it validates.
if (strpos($entity->mail, '@default.invalid') !== FALSE) {
$entity->mail = substr($entity->mail, 0, strpos($entity->mail, '@default.invalid')) . '@example.com';
}
foreach ($entity as &$value) {
if (is_array($value) && isset($value[LANGUAGE_NONE][0]['value'])) {
$value[LANGUAGE_NONE][0]['value'] = substr($value[LANGUAGE_NONE][0]['value'], 0, 10);
}
if (is_array($value) && isset($value[LANGUAGE_NONE][0]['safe_value'])) {
$value[LANGUAGE_NONE][0]['safe_value'] = substr($value[LANGUAGE_NONE][0]['safe_value'], 0, 10);
}
}
}
}
}