2525use Psr \Log \LoggerAwareInterface ;
2626use Psr \Log \LoggerAwareTrait ;
2727use Psr \Log \LoggerTrait ;
28- use Symfony \Component \Serializer \Serializer ;
2928
3029/**
3130 * A helper class for the module.
@@ -47,7 +46,6 @@ class Helper implements LoggerAwareInterface {
4746 */
4847 public function __construct (
4948 readonly private PrivateTempStoreFactory $ tempStoreFactory ,
50- readonly private Serializer $ serializer ,
5149 readonly private StateInterface $ state ,
5250 readonly private FileUrlGenerator $ fileUrlGenerator ,
5351 readonly private RouteMatchInterface $ routeMatch ,
@@ -65,11 +63,10 @@ public function __construct(
6563 * @return object|null
6664 * The entity or NULL if no valid entity was found.
6765 */
68- public function getDraftProposal (): ?object {
69- $ entitySerialized = $ this ->getProposalStorage ()->get (self ::CITIZEN_PROPOSAL_ENTITY );
70- $ node = is_string ($ entitySerialized ) ? $ this ->serializer ->deserialize ($ entitySerialized , Node::class, 'json ' ) : NULL ;
66+ public function getDraftProposal (): ?NodeInterface {
67+ $ entity = $ this ->getProposalStorage ()->get (self ::CITIZEN_PROPOSAL_ENTITY );
7168
72- return isset ( $ node ) && $ node instanceof Node ? $ node : NULL ;
69+ return $ entity instanceof NodeInterface ? $ entity : NULL ;
7370 }
7471
7572 /**
@@ -93,11 +90,10 @@ public function deleteDraftProposal(): void {
9390 /**
9491 * Add entity to temp store.
9592 */
96- public function setDraftProposal ($ entity ): void {
97- $ nodeSerialized = $ this ->serializer ->serialize ($ entity , 'json ' );
93+ public function setDraftProposal (NodeInterface $ entity ): void {
9894 try {
9995 $ this ->getProposalStorage ()->set (
100- self ::CITIZEN_PROPOSAL_ENTITY , $ nodeSerialized
96+ self ::CITIZEN_PROPOSAL_ENTITY , $ entity
10197 );
10298 }
10399 catch (\Exception $ exception ) {
@@ -514,7 +510,7 @@ public function isActive(NodeInterface $node): bool {
514510 /**
515511 * Get vote end date.
516512 */
517- public function getVoteEndDate (NodeInterface $ node ): int {
513+ public function getVoteEndDate (NodeInterface $ node ): ? int {
518514 if (!$ this ->isCitizenProposal ($ node )) {
519515 return NULL ;
520516 }
0 commit comments