Skip to content

Commit

Permalink
Merge pull request #11374 from creative-commoners/pulls/5/trait-const…
Browse files Browse the repository at this point in the history
…ructor

FIX Use correct constructors arguments
GuySartorelli authored Sep 12, 2024
2 parents 52e4574 + 4045443 commit b926834
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ORM/FieldType/DBClassNameTrait.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
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');
}
}

/**

0 comments on commit b926834

Please sign in to comment.