How to get object from File field type
Created 6 years ago by kiger

Hello everybody! I created a widget that stores a file. The problem is that I cannot get the File Object from the ConfigurationRepositoryInterface, I use the $configuration->get('kiger.extension.sections_widget::xmlfile', $this->widget->getId()) method but I only get the file's Id. Please help, what is the correct method to obtain the file? I know that with FileRepositoryInterface I can find the file ($files->find($xmlfile->getValue())) but I think it's not the correct way. Thanks.

aaronpeachey  —  6 years ago

I know it's been 8 months but I spent a while on figuring this out so in case someone else has the same issue getting the file object from the settings of configuration... I found once I had the file's ID, I could get the file object itself using $files->find($fileId)->resource() which returns a League\Flysystem\File object. (Where $files is a FileRepositoryInterface)