Skip to content

Commit

Permalink
Merge pull request #650 from creative-commoners/pulls/2/field-validat…
Browse files Browse the repository at this point in the history
…or-depr

API Add deprecation
  • Loading branch information
GuySartorelli authored Oct 20, 2024
2 parents 6b6fcbc + 908c59b commit b6b78b3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Storage/DBFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Assets\Thumbnail;
use SilverStripe\Control\Director;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\FieldType\DBComposite;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\ValidationResult;
Expand Down Expand Up @@ -503,15 +504,28 @@ protected function assertFilenameValid($filename)
}
}


/**
* Hook to validate this record against a validation result
*
* @param ValidationResult $result
* @param string $filename Optional filename to validate. If omitted, the current value is validated.
* @return bool Valid flag
* @deprecated 2.4.0 Use validateFilename() instead
*/
public function validate(ValidationResult $result, $filename = null)
{
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('2.4.0', 'Use validateFilename() instead');
});
return $this->validateFilename($result, $filename);
}

/**
* Hook to validate this record against a validation result
*
* @param string $filename Optional filename to validate. If omitted, the current value is validated.
*/
public function validateFilename(ValidationResult $result, $filename = null): bool
{
if (empty($filename)) {
$filename = $this->getFilename();
Expand Down

0 comments on commit b6b78b3

Please sign in to comment.