Dialog API
The API provides functionality for interacting with files and directories through dialog windows.
You can access the subsystem using Application::$dialog
property.
Select File
To select a single file from the file system, use the selectFile
method. The method will return the path to the file as a string
after it is selected. If the user declines the operation during the selection, the method will return null
.
The method takes two optional arguments. The first one is responsible for the directory in which the dialog window will be opened.
The second argument contains a list of filters for selecting files.
Select Multiple Files
If you need to select multiple files, you should use the selectFiles
method. The method always returns an array
of the selected files, and if the process is canceled, the array will be empty.
Just like with single file selection, this method takes two optional arguments with a $directory
and a $filter
.
Select Directory
To call the dialog window with directory selection, call the selectDirectory
method. Unlike file selection, this dialog allows you to select only a specific directory.
Just like with single file selection, this method takes two optional arguments with a $directory
and a $filter
.
Select Multiple Directories
If you need to select multiple directories, you should use the selectDirectories
method. The method always returns an array
of the selected directories, and if selection process is canceled, the array will be empty.
Just like with single file selection, this method takes two optional arguments with a $directory
and a $filter
.
Open File
You can open any address (URI or file) using a registered program. For example, when trying to open https://bosonphp.com
, most likely (depending on your OS settings) a browser with the specified address will be opened, and when trying to open example.txt
, a text editor.