Initial Drupal 11 with DDEV setup
This commit is contained in:
@ -0,0 +1,5 @@
|
||||
name: 'Path test miscellaneous utilities'
|
||||
type: module
|
||||
description: 'Utilities for path testing'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\path_test_misc\Hook;
|
||||
|
||||
use Drupal\Core\Hook\Attribute\Hook;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
/**
|
||||
* Hook implementations for path_test_misc.
|
||||
*/
|
||||
class PathTestMiscHooks {
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_presave() for node entities.
|
||||
*
|
||||
* This is invoked from testAliasDuplicationPrevention.
|
||||
*/
|
||||
#[Hook('node_presave')]
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
name: 'Path test with node grants'
|
||||
type: module
|
||||
description: 'Tests URL alias with hook_node_grants implementation'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\path_test_node_grants\Hook;
|
||||
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Hook\Attribute\Hook;
|
||||
|
||||
/**
|
||||
* Hook implementations for path_test_node_grants.
|
||||
*/
|
||||
class PathTestNodeGrantsHooks {
|
||||
|
||||
/**
|
||||
* Implements hook_node_grants().
|
||||
*/
|
||||
#[Hook('node_grants')]
|
||||
public function nodeGrants(AccountInterface $account, $operation) : array {
|
||||
$grants = [];
|
||||
return $grants;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user