Loading modules/config/src/Payload.php +2 −2 Original line number Diff line number Diff line Loading @@ -57,8 +57,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static(); public static function createFromArray(array $payload): ?PayloadInterface { return new Payload(); } /** Loading modules/content/src/Payload.php +9 −16 Original line number Diff line number Diff line Loading @@ -107,25 +107,12 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { public static function createFromArray(array $payload): ?PayloadInterface { try { $storage = \Drupal::entityTypeManager()->getStorage($payload['entity']['type']); } catch (InvalidPluginDefinitionException $e) { } catch (PluginNotFoundException $e) { } /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($storage)) { // Entity type does not exist anymore, created a dummy entity and don't save it. $entity = Event::create([ 'label' => 'Content type ' . $payload['entity']['type'] . ' no longer exists.', ]); } else { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $storage->load($payload['entity']['id']); if (empty($entity)) { if ($entity === NULL) { // Entity got deleted, created a dummy entity and don't save it. $entity = $storage->create([ $storage->getEntityType()->getKey('bundle') => $payload['entity']['bundle'], Loading @@ -134,7 +121,13 @@ final class Payload extends PayloadBase { ]); } } return new static($entity); catch (InvalidPluginDefinitionException | PluginNotFoundException $e) { // Entity type does not exist, create a dummy entity and don't save it. $entity = Event::create([ 'label' => 'Content type ' . $payload['entity']['type'] . ' no longer exists.', ]); } return new Payload($entity); } /** Loading modules/form/src/Payload.php +3 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\danse\Entity\Event; use Drupal\danse\Entity\EventInterface; use Drupal\danse\PayloadBase; use Drupal\danse\PayloadInterface; use Drupal\Core\Form\FormState; /** * Class Payload. Loading Loading @@ -71,8 +72,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static($payload['form'], unserialize($payload['form_state'], ['allowed_classes' => ['Drupal\Core\Form\FormState']])); public static function createFromArray(array $payload): ?PayloadInterface { return new Payload($payload['form'], unserialize($payload['form_state'], ['allowed_classes' => [FormState::class]])); } /** Loading modules/log/src/Payload.php +2 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static( public static function createFromArray(array $payload): ?PayloadInterface { return new Payload( $payload['level'], $payload['message'], $payload['context'] Loading modules/user/src/Payload.php +5 −3 Original line number Diff line number Diff line Loading @@ -65,10 +65,12 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { public static function createFromArray(array $payload): ?PayloadInterface { /** @var \Drupal\user\UserInterface $user */ $user = User::load($payload['account']); return new static($user); if ($user = User::load($payload['account'])) { return new Payload($user); } return NULL; } /** Loading Loading
modules/config/src/Payload.php +2 −2 Original line number Diff line number Diff line Loading @@ -57,8 +57,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static(); public static function createFromArray(array $payload): ?PayloadInterface { return new Payload(); } /** Loading
modules/content/src/Payload.php +9 −16 Original line number Diff line number Diff line Loading @@ -107,25 +107,12 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { public static function createFromArray(array $payload): ?PayloadInterface { try { $storage = \Drupal::entityTypeManager()->getStorage($payload['entity']['type']); } catch (InvalidPluginDefinitionException $e) { } catch (PluginNotFoundException $e) { } /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($storage)) { // Entity type does not exist anymore, created a dummy entity and don't save it. $entity = Event::create([ 'label' => 'Content type ' . $payload['entity']['type'] . ' no longer exists.', ]); } else { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $storage->load($payload['entity']['id']); if (empty($entity)) { if ($entity === NULL) { // Entity got deleted, created a dummy entity and don't save it. $entity = $storage->create([ $storage->getEntityType()->getKey('bundle') => $payload['entity']['bundle'], Loading @@ -134,7 +121,13 @@ final class Payload extends PayloadBase { ]); } } return new static($entity); catch (InvalidPluginDefinitionException | PluginNotFoundException $e) { // Entity type does not exist, create a dummy entity and don't save it. $entity = Event::create([ 'label' => 'Content type ' . $payload['entity']['type'] . ' no longer exists.', ]); } return new Payload($entity); } /** Loading
modules/form/src/Payload.php +3 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\danse\Entity\Event; use Drupal\danse\Entity\EventInterface; use Drupal\danse\PayloadBase; use Drupal\danse\PayloadInterface; use Drupal\Core\Form\FormState; /** * Class Payload. Loading Loading @@ -71,8 +72,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static($payload['form'], unserialize($payload['form_state'], ['allowed_classes' => ['Drupal\Core\Form\FormState']])); public static function createFromArray(array $payload): ?PayloadInterface { return new Payload($payload['form'], unserialize($payload['form_state'], ['allowed_classes' => [FormState::class]])); } /** Loading
modules/log/src/Payload.php +2 −2 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { return new static( public static function createFromArray(array $payload): ?PayloadInterface { return new Payload( $payload['level'], $payload['message'], $payload['context'] Loading
modules/user/src/Payload.php +5 −3 Original line number Diff line number Diff line Loading @@ -65,10 +65,12 @@ final class Payload extends PayloadBase { /** * {@inheritdoc} */ public static function createFromArray(array $payload): PayloadInterface { public static function createFromArray(array $payload): ?PayloadInterface { /** @var \Drupal\user\UserInterface $user */ $user = User::load($payload['account']); return new static($user); if ($user = User::load($payload['account'])) { return new Payload($user); } return NULL; } /** Loading