Guest User

Untitled

a guest
Dec 11th, 2023
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Espo\Custom\Hooks\Connection;
  4.  
  5.  
  6. use Espo\ORM\Entity;
  7. use Espo\ORM\EntityManager;
  8. use Espo\Core\Record\ReadParams;
  9. use Espo\Core\Record\Hook\ReadHook;
  10.  
  11. class HasBeenRead implements ReadHook
  12. {
  13. #private EntityManager $entityManager;
  14. private $entityManager;
  15.  
  16. #public function __construct(EntityManager $entityManager)
  17. public function __construct(EntityManagerInterface $entityManager)
  18. {
  19. $this->entityManager = $entityManager;
  20. }
  21.  
  22. public function process(Entity $entity, ReadParams $params): void
  23. {
  24. logger("Calling read hook!");
  25.  
  26. $entity->set('status', 'Read');
  27. $this->entityManager->saveEntity($entity);
  28. }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment