2015-08-18 00:00:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Hooks provided by the Path module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup hooks
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to a path being inserted.
|
|
|
|
*
|
|
|
|
* @param array $path
|
|
|
|
* The array structure is identical to that of the return value of
|
2018-11-23 12:29:20 +00:00
|
|
|
* \Drupal\Core\Path\AliasStorageInterface::save().
|
2015-08-18 00:00:26 +00:00
|
|
|
*
|
2018-11-23 12:29:20 +00:00
|
|
|
* @see \Drupal\Core\Path\AliasStorageInterface::save()
|
2015-08-18 00:00:26 +00:00
|
|
|
*/
|
|
|
|
function hook_path_insert($path) {
|
|
|
|
db_insert('mytable')
|
2017-04-13 14:53:35 +00:00
|
|
|
->fields([
|
2015-08-18 00:00:26 +00:00
|
|
|
'alias' => $path['alias'],
|
|
|
|
'pid' => $path['pid'],
|
2017-04-13 14:53:35 +00:00
|
|
|
])
|
2015-08-18 00:00:26 +00:00
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to a path being updated.
|
|
|
|
*
|
|
|
|
* @param array $path
|
|
|
|
* The array structure is identical to that of the return value of
|
2018-11-23 12:29:20 +00:00
|
|
|
* \Drupal\Core\Path\AliasStorageInterface::save().
|
2015-08-18 00:00:26 +00:00
|
|
|
*
|
2018-11-23 12:29:20 +00:00
|
|
|
* @see \Drupal\Core\Path\AliasStorageInterface::save()
|
2015-08-18 00:00:26 +00:00
|
|
|
*/
|
|
|
|
function hook_path_update($path) {
|
|
|
|
if ($path['alias'] != $path['original']['alias']) {
|
|
|
|
db_update('mytable')
|
2017-04-13 14:53:35 +00:00
|
|
|
->fields(['alias' => $path['alias']])
|
2015-08-18 00:00:26 +00:00
|
|
|
->condition('pid', $path['pid'])
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to a path being deleted.
|
|
|
|
*
|
|
|
|
* @param array $path
|
|
|
|
* The array structure is identical to that of the return value of
|
2018-11-23 12:29:20 +00:00
|
|
|
* \Drupal\Core\Path\AliasStorageInterface::save().
|
2015-08-18 00:00:26 +00:00
|
|
|
*
|
2018-11-23 12:29:20 +00:00
|
|
|
* @see \Drupal\Core\Path\AliasStorageInterface::delete()
|
2015-08-18 00:00:26 +00:00
|
|
|
*/
|
|
|
|
function hook_path_delete($path) {
|
|
|
|
db_delete('mytable')
|
|
|
|
->condition('pid', $path['pid'])
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @} End of "addtogroup hooks".
|
|
|
|
*/
|