-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDST-382: Subscriber to handle deletion of related Embargoes when a n…
…ode is deleted
- Loading branch information
1 parent
935129a
commit bca65aa
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Drupal\islandora_entity_status; | ||
|
||
use Drupal\Core\Entity\EntityTypeManagerInterface; | ||
use Drupal\node\NodeInterface; | ||
|
||
class IslandoraNodeDeleteSubscriber { | ||
|
||
/** | ||
* The entity type manager. | ||
* | ||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface | ||
*/ | ||
protected $entityTypeManager; | ||
|
||
/** | ||
* Constructs a new CustomEntityDeleter object. | ||
* | ||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager | ||
* The entity type manager. | ||
*/ | ||
public function __construct(EntityTypeManagerInterface $entity_type_manager) { | ||
$this->entityTypeManager = $entity_type_manager; | ||
} | ||
|
||
/** | ||
* Deletes the associated custom entity. | ||
* | ||
* @param \Drupal\node\NodeInterface $node | ||
* The Islandora object node being deleted. | ||
*/ | ||
public function deleteAssociatedCustomEntity(NodeInterface $node): void { | ||
// Replace 'your_custom_entity_type' with the actual machine name of your custom entity type. | ||
$custom_entity_storage = $this->entityTypeManager->getStorage('embargo'); | ||
$custom_entities = $custom_entity_storage->loadByProperties(['embargoed_node' => $node->id()]); | ||
|
||
foreach ($custom_entities as $custom_entity) { | ||
$custom_entity->delete(); | ||
} | ||
} | ||
} |