@@ -51,10 +51,11 @@ public function loadEntityFiles(object $entity): void
5151 array_walk (
5252 $ configurations ,
5353 function (FilePropertyConfiguration $ configuration , $ key , object $ entity ): void {
54- $ configuration ->getFilePropertyReflection ()->setValue (
55- $ entity ,
56- $ this ->fromEntity ($ configuration , $ entity )
57- );
54+ $ file = $ this ->fromEntity ($ configuration , $ entity );
55+ $ configuration ->getFilePropertyReflection ()->setValue ($ entity , $ file );
56+ if (null !== $ file ) {
57+ $ this ->checkFileExistenceIfEnabled ($ configuration , $ file );
58+ }
5859 },
5960 $ entity
6061 );
@@ -75,12 +76,7 @@ public function fromEntity(FilePropertyConfiguration $configuration, object $ent
7576 return null ;
7677 }
7778
78- $ file = $ this ->fileManager ->load ($ configuration ->getFileSystemName (), $ path );
79- if (null !== $ file ) {
80- $ this ->checkFileExistenceIfEnabled ($ className , $ file );
81- }
82-
83- return $ file ;
79+ return $ this ->fileManager ->load ($ configuration ->getFileSystemName (), $ path );
8480 }
8581
8682 public function disableFileExistenceChecksOnLoad (): void
@@ -112,16 +108,17 @@ public function enableClassFileExistenceChecksOnLoad(string $className): void
112108 }
113109
114110 /**
115- * @param class-string<object> $className
111+ * @param FilePropertyConfiguration $configuration
116112 * @param WebFile $file
117113 * @return void
118114 */
119- private function checkFileExistenceIfEnabled (string $ className , WebFile $ file ): void
115+ public function checkFileExistenceIfEnabled (FilePropertyConfiguration $ configuration , WebFile $ file ): void
120116 {
121117 if (false === $ this ->fileExistenceChecksOnLoad ) {
122118 return ;
123119 }
124120
121+ $ className = $ configuration ->getEntityClass ();
125122 if (false === array_key_exists ($ className , $ this ->classFileExistenceChecksOnLoad )) {
126123 $ this ->classFileExistenceChecksOnLoad [$ className ] = true ;
127124 }
0 commit comments