This code works but $menu_links sometimes has multiple links. The Menu UI module somehow keeps track of only a single menu link even if there are multiple links in the same menu to that node. I'm calling this the menu ui link, though maybe there's a better way to refer to it.
In my site, Some media's assets are stored in private folder. I have a custom form where i am using these media assets. When user load the page they are granted the access to use those medias by "private file download access" module. My question is when user submit the form. These media should be also save in public folder. I am doing this by file_get_contents() function (download file from url). See the below code:
I thought I could figure this out, reading the Entity\File.php class governing this entity.
Through a theme, I've uploaded an image in its logo upload form in its settings. I see the file in managed_file with a URI of 'temporary://mylogo.jpg'and a status of 0 which indicates to me that it's in a temporary state that will be destroyed during the next cron run.