Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"require-dev": {
"phpunit/phpunit": "^9.5",
"spiral/tokenizer": "^2.8",
"vimeo/psalm": "^5.12",
"vimeo/psalm": "^5.12 || ^6.10",
"symfony/console": "^6.0 || ^7.0",
"spiral/code-style": "^2.2"
},
Expand Down
8 changes: 7 additions & 1 deletion src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ private function renderColumns(Entity $entity): array
$fieldGroups = [];
// Collect and group fields by column name
foreach ($entity->getFields() as $name => $field) {
if ($field->getAttributes()->get('obsolete')) {
continue;
}
$fieldGroups[$field->getColumn()][$name] = $field;
}
foreach ($fieldGroups as $fields) {
Expand All @@ -182,6 +185,9 @@ private function renderColumns(Entity $entity): array

$schema = [];
foreach ($entity->getFields() as $name => $field) {
if ($field->getAttributes()->get('obsolete')) {
continue;
}
$schema[$name] = $field->getColumn();
}

Expand All @@ -204,7 +210,7 @@ private function renderTypecast(Entity $entity): array
{
$schema = [];
foreach ($entity->getFields() as $name => $field) {
if ($field->hasTypecast()) {
if ($field->hasTypecast() && !$field->getAttributes()->get('obsolete')) {
$schema[$name] = $field->getTypecast();
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/Definition/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ public function setEntityClass(?string $entityClass): self
return $this;
}

public function isObsolete(): bool
{
return $this->obsolete;
}

public function setObsolete(bool $obsolete): void
{
$this->obsolete = $obsolete;
}

public function __clone()
{
$this->options = clone $this->options;
Expand Down
5 changes: 5 additions & 0 deletions src/Generator/GenerateRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ final class GenerateRelations implements GeneratorInterface
'indexCreate' => RelationSchema::INDEX_CREATE,
'morphKeyLength' => RelationSchema::MORPH_KEY_LENGTH,
'embeddedPrefix' => RelationSchema::EMBEDDED_PREFIX,
'obsolete' => Relation::OBSOLETE,

// deprecated
'though' => Relation::THROUGH_ENTITY,
Expand Down Expand Up @@ -110,6 +111,10 @@ protected function register(Registry $registry, Entity $entity): void
\assert($role !== null);

foreach ($entity->getRelations() as $name => $r) {
if ($r->getOptions()->get('obsolete') === true) {
continue;
}

$schema = $this->initRelation($r->getType())->withContext(
$name,
$role,
Expand Down
Loading