murph-doc/docs/utils/file_attribute.md
Simon Vieille 385af624a6
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
update theme
2023-02-09 21:50:06 +01:00

23 lines
703 B
Markdown

# File attribute
`App\Core\File\FileAttribute::handleFile` transforms a file path to an instance of `Symfony\Component\HttpFoundation\File\File`. You can specify another class if needed.
If the path is `null` or if the file does not exist, it returns `null`.
```php-inline
use App\Core\File\FileAttribute;
use App\Foo\Bar;
$path = 'path/to/file';
$file = FileAttribute::handleFile($path); // returns an instance of File
$path = 'path/to/file';
$file = FileAttribute::handleFile($path, Bar::class); // returns an instance of Bar
$path = 'path/to/removed_file';
$file = FileAttribute::handleFile($path); // returns null
$path = null;
$file = FileAttribute::handleFile($path); // returns null
```