Symfony\Component\HttpFoundation\File\File::__construct PHP Method

__construct() public method

Constructs a new file from the given path.
public __construct ( string $path, boolean $checkPath = true )
$path string The path to the file
$checkPath boolean Whether to check the path or not
    public function __construct($path, $checkPath = true)
    {
        if ($checkPath && !is_file($path)) {
            throw new FileNotFoundException($path);
        }

        parent::__construct($path);
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($path, $checkPath = true)
 {
     parent::__construct($path, $checkPath);
     if (false === strpos($this->getMimeType(), 'image')) {
         throw new \Exception(sprintf('Is not an image file. (%s)', $this->getMimeType()));
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\File\File::__construct