@@ -50,6 +50,9 @@ public function __construct(
5050 public function save (array $ data ): FileEntity {
5151 $ file = $ this ->saveFile ($ data );
5252 $ this ->saveVisibleElements ($ data , $ file );
53+ if (empty ($ data ['status ' ])) {
54+ $ data ['status ' ] = $ file ->getStatus ();
55+ }
5356 $ this ->associateToSigners ($ data , $ file ->getId ());
5457 return $ file ;
5558 }
@@ -190,7 +193,7 @@ private function associateToSigners(array $data, int $fileId): array {
190193 ],
191194 displayName: $ user ['displayName ' ] ?? '' ,
192195 description: $ user ['description ' ] ?? '' ,
193- notify: empty ($ user ['notify ' ]),
196+ notify: empty ($ user ['notify ' ]) && $ this -> isStatusAbleToNotify ( $ data [ ' status ' ] ?? null ) ,
194197 fileId: $ fileId ,
195198 );
196199 }
@@ -199,7 +202,7 @@ private function associateToSigners(array $data, int $fileId): array {
199202 identifyMethods: $ user ['identify ' ],
200203 displayName: $ user ['displayName ' ] ?? '' ,
201204 description: $ user ['description ' ] ?? '' ,
202- notify: empty ($ user ['notify ' ]),
205+ notify: empty ($ user ['notify ' ]) && $ this -> isStatusAbleToNotify ( $ data [ ' status ' ] ?? null ) ,
203206 fileId: $ fileId ,
204207 );
205208 }
@@ -208,6 +211,13 @@ private function associateToSigners(array $data, int $fileId): array {
208211 return $ return ;
209212 }
210213
214+ private function isStatusAbleToNotify (?int $ status ): bool {
215+ return in_array ($ status , [
216+ FileEntity::STATUS_ABLE_TO_SIGN ,
217+ FileEntity::STATUS_PARTIAL_SIGNED ,
218+ ]);
219+ }
220+
211221 private function associateToSigner (array $ identifyMethods , string $ displayName , string $ description , bool $ notify , int $ fileId ): SignRequestEntity {
212222 $ identifyMethodsIncances = $ this ->identifyMethod ->getByUserData ($ identifyMethods );
213223 if (empty ($ identifyMethodsIncances )) {
0 commit comments