protected function validateHandler($file, $extension = null)
    {
        if (empty($this->handler['validator'])) {
            throw new UnexpectedValueException($this->translation->text('Unknown handler'));
        }

        if (!empty($this->handler['extensions']) && isset($extension) && !in_array($extension, $this->handler['extensions'])) {
            throw new RuntimeException($this->translation->text('Unsupported file extension'));
        }

        if (isset($this->handler['filesize']) && filesize($file) > $this->handler['filesize']) {
            throw new RuntimeException($this->translation->text('File size exceeds %num bytes', array(
                '%num' => $this->handler['filesize'])));
        }

        $result = $this->validator->run($this->handler['validator'], $file, $this->handler);

        if ($result !== true) {
            throw new UnexpectedValueException($result);
        }

        return true;
    }
protected function validateHandler($file, $extension = null)
    {
        if (empty($this->handler['validator'])) {
            throw new UnexpectedValueException($this->translation->text('Unknown handler'));
        }

        if (!empty($this->handler['extensions']) && isset($extension) && !in_array($extension, $this->handler['extensions'])) {
            throw new RuntimeException($this->translation->text('Unsupported file extension'));
        }

        if (isset($this->handler['filesize']) && filesize($file) > $this->handler['filesize']) {
            throw new RuntimeException($this->translation->text('File size exceeds %num bytes', array(
                '%num' => $this->handler['filesize'])));
        }

        $result = $this->validator->run($this->handler['validator'], $file, $this->handler);

        if ($result !== true) {
            throw new UnexpectedValueException($result);
        }

        return true;
    }
protected function validateHandler ( $ file , $ extension = null ) { if ( empty ( $ this -> handler [ 'validator' ] ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Unknown handler' ) ) ; } if ( ! empty ( $ this -> handler [ 'extensions' ] ) && isset ( $ extension ) && ! in_array ( $ extension , $ this -> handler [ 'extensions' ] ) ) { throw new RuntimeException ( $ this -> translation -> text ( 'Unsupported file extension' ) ) ; } if ( isset ( $ this -> handler [ 'filesize' ] ) && filesize ( $ file ) > $ this -> handler [ 'filesize' ] ) { throw new RuntimeException ( $ this -> translation -> text ( 'File size exceeds %num bytes' , array ( '%num' => $ this -> handler [ 'filesize' ] ) ) ) ; } $ result = $ this -> validator -> run ( $ this -> handler [ 'validator' ] , $ file , $ this -> handler ) ; if ( $ result !== true ) { throw new UnexpectedValueException ( $ result ) ; } return true ; }
Validates a file using a validator
@param string $file
@param string|null $extension
@return bool
@throws UnexpectedValueException
@throws RuntimeException
Validates a file using a validator