function record_shorten_shorten_create in Shorten URLs 8.2
Same name and namespace in other branches
- 8 modules/record_shorten/record_shorten.module \record_shorten_shorten_create()
- 6 record_shorten.module \record_shorten_shorten_create()
- 7.2 record_shorten.module \record_shorten_shorten_create()
- 7 record_shorten.module \record_shorten_shorten_create()
Implements hook_shorten_create().
File
- modules/
record_shorten/ record_shorten.module, line 28
Code
function record_shorten_shorten_create($old, $new, $service) {
$array = [
'original' => $old,
'short' => $new,
'service' => $service,
'uid' => \Drupal::currentUser()
->id(),
'hostname' => \Drupal::request()
->getClientIp(),
'created' => \Drupal::time()
->getRequestTime(),
];
// @TODO : This creates duplicate records. Needs to be fixed.
\Drupal::database()
->merge('record_shorten')
->key($array)
->fields($array)
->execute();
}