23 lines
703 B
Markdown
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
|
|
|
|
```
|