class PathTestMiscHooks
Hook implementations for path_test_misc.
Hierarchy
- class \Drupal\path_test_misc\Hook\PathTestMiscHooks
Expanded class hierarchy of PathTestMiscHooks
File
-
core/
modules/ path/ tests/ modules/ path_test_misc/ src/ Hook/ PathTestMiscHooks.php, line 13
Namespace
Drupal\path_test_misc\HookView source
class PathTestMiscHooks {
/**
* Implements hook_ENTITY_TYPE_presave() for node entities.
*
* This is invoked from testAliasDuplicationPrevention.
*/
public function nodePresave(NodeInterface $node) : void {
if ($node->getTitle() !== 'path duplication test') {
return;
}
// Update the title to be able to check that this code ran.
$node->setTitle('path duplication test ran');
// Create a path alias that has the same values as the one in
// PathItem::postSave.
$path = \Drupal::entityTypeManager()->getStorage('path_alias')
->create([
'path' => '/node/1',
'alias' => '/my-alias',
'langcode' => 'en',
]);
$path->save();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.