Merge pull request #11374 from creative-commoners/pulls/5/trait-constructor

FIX Use correct constructors arguments
This commit is contained in:
Guy Sartorelli 2024-09-12 14:03:59 +12:00 committed by GitHub
commit b926834fb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ namespace SilverStripe\ORM\FieldType;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject;
use RuntimeException;
trait DBClassNameTrait
{
@ -36,7 +37,13 @@ trait DBClassNameTrait
public function __construct($name = null, $baseClass = null, $options = [])
{
$this->setBaseClass($baseClass);
parent::__construct($name, null, null, $options);
if (is_a($this, DBVarchar::class)) {
parent::__construct($name, 255, $options);
} elseif (is_a($this, DBEnum::class)) {
parent::__construct($name, null, null, $options);
} else {
throw new RuntimeException('DBClassNameTrait can only be used with DBVarchar or DBEnum');
}
}
/**