Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Sep 20, 2023
1 parent 178519c commit 7967fe9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
1 change: 0 additions & 1 deletion databox/api/config/validator/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ App\Entity\Core\Attribute:

App\Entity\Core\AbstractBaseAttribute:
constraints:
- App\Validator\UniqueAttributeConstraint: ~
- App\Validator\ValidAttributeConstraint: ~
properties:
value:
Expand Down
52 changes: 52 additions & 0 deletions databox/api/migrations/Version20230920160828.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230920160828 extends AbstractMigration
{
public function getDescription(): string
{
return 'Migrate from "array" to "json" Doctrine type';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE attribute_definition ALTER fallback TYPE JSON USING fallback::json');
$this->addSql('COMMENT ON COLUMN attribute_definition.fallback IS NULL');
$this->addSql('ALTER TABLE file ALTER alternate_urls TYPE JSON USING alternate_urls::json');
$this->addSql('COMMENT ON COLUMN file.alternate_urls IS NULL');

$connection = $this->connection;

foreach ([
['attribute_definition', 'fallback'],
['file', 'alternate_urls'],
] as $t)
{
[$table, $column] = $t;
$rows = $connection->fetchAllAssociative(sprintf('SELECT "id", "%s" FROM "%s"', $column, $table));

foreach ($rows as $row) {
$connection->executeStatement(sprintf('UPDATE "%s" SET "%s" = :encodedData WHERE id = :id', $table, $column), [
'encodedData' => json_encode(unserialize($row[$column])),
'id' => $row['id'],
]);
}
}
}

public function down(Schema $schema): void
{
throw new \InvalidArgumentException('Cannot revert');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Validator;

use App\Attribute\AttributeTypeRegistry;
use App\Entity\Core\Attribute;
use App\Entity\Core\AbstractBaseAttribute;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

Expand All @@ -16,7 +16,7 @@ public function __construct(private readonly AttributeTypeRegistry $typeRegistry
}

/**
* @param Attribute $value
* @param AbstractBaseAttribute $value
* @param SameWorkspaceConstraint $constraint
*/
public function validate($value, Constraint $constraint): void
Expand Down
1 change: 1 addition & 0 deletions lib/php/admin-bundle/Field/IdField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static function new(string $propertyName = 'id', $label = null): BaseIdFi
}

return BaseIdField::new($propertyName, $label)
->hideOnForm()
->setTemplatePath('@AlchemyAdmin/list/id.html.twig');
}
}

0 comments on commit 7967fe9

Please sign in to comment.