Skip to content

Commit

Permalink
Merge pull request #10 from adrianodias8/#9_canProcess_error_on_Entit…
Browse files Browse the repository at this point in the history
…yCreate

canProcess error on EntityCreate
  • Loading branch information
adrianodias8 authored Apr 2, 2020
2 parents 2d5ab8c + 79edbe5 commit e60e711
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Plugin/ActivityProcessor/EntityCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ protected function getExistingEntities(EntityActivityTrackerInterface $tracker)
public function canProcess(Event $event) {
// This should change since doesn't make sense to store Entity in event to then
// load it again.
$entity = $event->getEntity();
$exists = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->load($entity->id());
if (empty($exists) && $event->getDispatcherType() == ActivityEventInterface::ENTITY_INSERT) {
return ActivityProcessorInterface::SKIP;
if ($event->getDispatcherType() == ActivityEventInterface::ENTITY_INSERT){
$entity = $event->getEntity();
$exists = $this->entityTypeManager->getStorage($entity->getEntityTypeId())->load($entity->id());
if (empty($exists)) {
return ActivityProcessorInterface::SKIP;
}
}
return ActivityProcessorInterface::PROCESS;
}
Expand Down

0 comments on commit e60e711

Please sign in to comment.