- WIP on Notes v2.x

This commit is contained in:
mcndave committed 2024-05-09 19:49:27 +00:00
1 parent 1dd9da6eb6
commit 75231f32b3
7 files changed
+104 -156

No files matched your search

+15 -11
View File
@@ -2,6 +2,7 @@
namespace Ulmus\Migration;
use Notes\Common\ReflectedProperty;
use Ulmus\Adapter\AdapterInterface;
use Ulmus\Annotation\Property\Field;
use Ulmus\Attribute;
@@ -29,25 +30,28 @@ class FieldDefinition {
public AdapterInterface $adapter;
public function __construct(AdapterInterface $adapter, array $data)
public function __construct(AdapterInterface $adapter, ReflectedProperty $data)
{
$this->adapter = $adapter;
$this->name = $data['name'];
$this->builtIn = $data['builtin'];
$this->tags = $data['tags'];
# Patch coming soon
$type = $data->getTypes()[0];
if (isset($data['value'])) {
$this->default = $data['value'];
$this->name = $data->name;
$this->builtIn = $type->builtIn;
$this->tags = $data->getAttributes();
if (isset($data->value)) {
$this->default = $data->value;
}
$field = $this->getFieldTag();
$adapter->whitelistAttributes($field->attributes);
$this->type = $field->type ?? $data['type'];
$this->type = $field->type ?? $type->type;
$this->length = $field->length ?? null;
$this->precision = $field->precision ?? null;
$this->nullable = $data['nullable'] ?: $field->nullable;
$this->nullable = $data->allowsNull() ?: $field->nullable;
$this->update = $field->attributes['update'] ?? null;
}
@@ -76,11 +80,11 @@ class FieldDefinition {
]));
}
public function getFieldTag() : Field|Attribute\Property\Field|null
public function getFieldTag() : Attribute\Property\Field|null
{
$field = array_filter($this->tags, fn($item) => $item['object'] instanceof Field || $item['object'] instanceof Attribute\Property\Field);
$field = array_filter($this->tags, fn($item) => $item->object instanceof Attribute\Property\Field);
return array_pop($field)['object'];
return array_pop($field)->object;
}
public function getColumnName() : ? string