0

The setup is the following: I client of mine wants to give users the possibility to select a background image for a page. For the sake of simplicity let's say we create a new field in the pages table and configure its TCA separately, so we are completely side-effect free.

Now comes the tricky part. The storage, the users should select images from for that field, should be limited. So even if a backend user has admin rights and therefore access to all file storages and all files, users should only be able to select images from a given(configured) storage.

Is that somehow possible with a specific TCA configuration?

1 Answers1

0

I would first try to extend FileBrowser for this requirement. As you said nothing about visibility of the files, you could override fileIsSelectableInFileList in a subclass. So not exactly a pure TCA feature, but the implementation would allow a deeper integration of your ruleset.

class LocalStorageBrowser extends FileBrowser {
    // users should only be able to select files from a specific driver
    protected function fileIsSelectableInFileList(FileInterface $file, array $imgInfo)
    {
        return $file->getStorage()->getDriver() instanceof LocalDriver;
    }
    // ...
}
Cedric Ziel
  • 1,052
  • 8
  • 21
  • Well, XClassing is always possible but not really my first choice. I hoped for a hidden configuration or such. :/ – Alexander Schnitzler Nov 17 '17 at 10:01
  • IMHO this is different from the traditional `hook into all FileBrowsers` XClassing since it's just a different Implentation for the FileBrowser and you can pin it just to your single field. – Cedric Ziel Nov 17 '17 at 10:06