Skip to content
Snippets Groups Projects

Minimal duplicate create hook implementation

2 unresolved threads

Closes #3040556

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 698 698 }
    699 699 }
    700 700
    701 /**
    702 * Implements hook_entity_duplicate_alter().
    703 */
    704 #[Hook('entity_duplicate_alter')]
    705 public function entityDuplicateAlter(EntityInterface $duplicate, EntityInterface $entity) : void {
    706 if ($duplicate instanceof ContentEntityInterface && $duplicate->label() === 'UUID CRUD test entity' && $duplicate->hasField('name')) {
  • 698 698 }
    699 699 }
    700 700
    701 /**
    702 * Implements hook_entity_duplicate_alter().
    703 */
    704 #[Hook('entity_duplicate_alter')]
    705 public function entityDuplicateAlter(EntityInterface $duplicate, EntityInterface $entity) : void {
    • For more complete test coverage, I think there should also be an implementation of the ENTITY_TYPE_duplicate_alter() hook for content entities.

    • I thought about that, but it would be a bit weird. we'd need pick one of the tested entity types and then exclude them in the generic hook. or do a completely separate test with yet another entity type. I'm not entirely sure if that's really worth it. If we add a custom Hook class maybe?

    • One approach could be to append a suffix to the to the entity_test name field in ENTITY_TYPE_duplicate_alter and then add another different suffix to the the name in entity_duplicate_alter. Then test the final string has both suffixes.

    • Please register or sign in to reply
  • added 1 commit

    • dbdd5930 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    • 7252d261 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 126 commits

    Compare with previous version

  • added 1 commit

    • 4e94448b - Also update hook in EntityBase

    Compare with previous version

  • added 101 commits

    Compare with previous version

  • closed

  • Please register or sign in to reply
    Loading