Compare commits
4 Commits
3c5fb83673
...
895df7415b
| Author | SHA1 | Date | |
|---|---|---|---|
| 895df7415b | |||
| 9abe9fea7f | |||
| ea45ce9d0a | |||
| 2c3fbb093a |
Submodule Inventory_frontend updated: 52f75c5301...2f3d4c5260
@@ -9,7 +9,8 @@ doctrine:
|
||||
profiling_collect_backtrace: '%kernel.debug%'
|
||||
orm:
|
||||
validate_xml_mapping: true
|
||||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
|
||||
naming_strategy: doctrine.orm.naming_strategy.default
|
||||
quote_strategy: doctrine.orm.quote_strategy.default
|
||||
identity_generation_preferences:
|
||||
Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
|
||||
auto_mapping: true
|
||||
|
||||
28
migrations/Version20261120120000.php
Normal file
28
migrations/Version20261120120000.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add email column to profiles when missing.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE profiles ADD COLUMN IF NOT EXISTS email VARCHAR(180) DEFAULT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS uniq_profiles_email ON profiles (email)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IF EXISTS uniq_profiles_email');
|
||||
$this->addSql('ALTER TABLE profiles DROP COLUMN IF EXISTS email');
|
||||
}
|
||||
}
|
||||
28
migrations/Version20261120123000.php
Normal file
28
migrations/Version20261120123000.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120123000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Ensure profiles.email exists (camelCase schema).';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS email VARCHAR(180) DEFAULT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS uniq_profiles_email ON public.profiles (email)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IF EXISTS uniq_profiles_email');
|
||||
$this->addSql('ALTER TABLE public.profiles DROP COLUMN IF EXISTS email');
|
||||
}
|
||||
}
|
||||
94
migrations/Version20261120124000.php
Normal file
94
migrations/Version20261120124000.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120124000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Normalize profiles columns to camelCase (quoted identifiers).';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'firstname'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN firstname TO "firstName";
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'lastname'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN lastname TO "lastName";
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'isactive'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN isactive TO "isActive";
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'createdat'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN createdat TO "createdAt";
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'updatedat'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN updatedat TO "updatedAt";
|
||||
END IF;
|
||||
END $$;
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'firstName'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN "firstName" TO firstname;
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'lastName'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN "lastName" TO lastname;
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'isActive'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN "isActive" TO isactive;
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'createdAt'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN "createdAt" TO createdat;
|
||||
END IF;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND table_name = 'profiles' AND column_name = 'updatedAt'
|
||||
) THEN
|
||||
ALTER TABLE public.profiles RENAME COLUMN "updatedAt" TO updatedat;
|
||||
END IF;
|
||||
END $$;
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
32
migrations/Version20261120125000.php
Normal file
32
migrations/Version20261120125000.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120125000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add missing profile auth columns (email, roles, password).';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS email VARCHAR(180) DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS roles JSON DEFAULT \'["ROLE_USER"]\' NOT NULL');
|
||||
$this->addSql('ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS password VARCHAR(255) DEFAULT NULL');
|
||||
$this->addSql('CREATE UNIQUE INDEX IF NOT EXISTS uniq_profiles_email ON public.profiles (email)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP INDEX IF EXISTS uniq_profiles_email');
|
||||
$this->addSql('ALTER TABLE public.profiles DROP COLUMN IF EXISTS password');
|
||||
$this->addSql('ALTER TABLE public.profiles DROP COLUMN IF EXISTS roles');
|
||||
$this->addSql('ALTER TABLE public.profiles DROP COLUMN IF EXISTS email');
|
||||
}
|
||||
}
|
||||
66
migrations/Version20261120131000.php
Normal file
66
migrations/Version20261120131000.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120131000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Normalize public schema identifiers to lowercase (tables + columns).';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql(<<<'SQL'
|
||||
DO $$
|
||||
DECLARE
|
||||
r RECORD;
|
||||
BEGIN
|
||||
-- Special-case legacy table name from Prisma.
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_name = 'ModelType'
|
||||
) THEN
|
||||
EXECUTE 'ALTER TABLE public."ModelType" RENAME TO model_types';
|
||||
END IF;
|
||||
|
||||
-- Rename columns containing uppercase letters.
|
||||
FOR r IN
|
||||
SELECT table_name, column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public' AND column_name ~ '[A-Z]'
|
||||
LOOP
|
||||
EXECUTE format(
|
||||
'ALTER TABLE public.%I RENAME COLUMN %I TO %I',
|
||||
r.table_name,
|
||||
r.column_name,
|
||||
lower(r.column_name)
|
||||
);
|
||||
END LOOP;
|
||||
|
||||
-- Rename tables containing uppercase letters.
|
||||
FOR r IN
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public' AND table_name ~ '[A-Z]'
|
||||
LOOP
|
||||
EXECUTE format(
|
||||
'ALTER TABLE public.%I RENAME TO %I',
|
||||
r.table_name,
|
||||
lower(r.table_name)
|
||||
);
|
||||
END LOOP;
|
||||
END $$;
|
||||
SQL);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// Irreversible: cannot restore original casing reliably.
|
||||
}
|
||||
}
|
||||
26
migrations/Version20261120140000.php
Normal file
26
migrations/Version20261120140000.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20261120140000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Convert custom_fields.options from text[] to json.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql("ALTER TABLE custom_fields ALTER COLUMN options TYPE JSON USING to_json(options)");
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql("ALTER TABLE custom_fields ALTER COLUMN options TYPE TEXT[] USING ARRAY(SELECT json_array_elements_text(options))");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
INSERT INTO public.profiles (id, firstname, lastname, isactive, createdat, updatedat)
|
||||
INSERT INTO public.profiles (id, firstname, lastname, email, isactive, createdat, updatedat)
|
||||
VALUES
|
||||
('admin-default-profile', 'Admin', 'General', true, '2025-09-23 13:09:47.804', '2025-09-23 13:09:47.804'),
|
||||
('cmhab2j3x003g47v77xhnm1ff', 'Elodie', 'Souriau', true, '2025-10-28 08:29:25.437', '2025-10-28 08:29:25.437')
|
||||
('admin-default-profile', 'Admin', 'General', 'admin@admin.fr', true, '2025-09-23 13:09:47.804', '2025-09-23 13:09:47.804'),
|
||||
('cmhab2j3x003g47v77xhnm1ff', 'Elodie', 'Souriau', 'elodie@gg.fr', true, '2025-10-28 08:29:25.437', '2025-10-28 08:29:25.437')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
@@ -400,13 +400,27 @@ class MachineSkeletonController extends AbstractController
|
||||
|
||||
private function normalizeMachine(Machine $machine): array
|
||||
{
|
||||
$site = $machine->getSite();
|
||||
$typeMachine = $machine->getTypeMachine();
|
||||
|
||||
return [
|
||||
'id' => $machine->getId(),
|
||||
'name' => $machine->getName(),
|
||||
'reference' => $machine->getReference(),
|
||||
'prix' => $machine->getPrix(),
|
||||
'siteId' => $machine->getSite()->getId(),
|
||||
'typeMachineId' => $machine->getTypeMachine()?->getId(),
|
||||
'siteId' => $site->getId(),
|
||||
'site' => [
|
||||
'id' => $site->getId(),
|
||||
'name' => $site->getName(),
|
||||
],
|
||||
'typeMachineId' => $typeMachine?->getId(),
|
||||
'typeMachine' => $typeMachine ? [
|
||||
'id' => $typeMachine->getId(),
|
||||
'name' => $typeMachine->getName(),
|
||||
'category' => $typeMachine->getCategory(),
|
||||
'description' => $typeMachine->getDescription(),
|
||||
] : null,
|
||||
'constructeurs' => $this->normalizeConstructeurs($machine->getConstructeurs()),
|
||||
'documents' => null,
|
||||
'customFieldValues' => null,
|
||||
];
|
||||
|
||||
110
src/Doctrine/QuoteStrategy/AlwaysQuoteStrategy.php
Normal file
110
src/Doctrine/QuoteStrategy/AlwaysQuoteStrategy.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Doctrine\QuoteStrategy;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\ORM\Internal\SQLResultCasing;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Mapping\JoinColumnMapping;
|
||||
use Doctrine\ORM\Mapping\ManyToManyOwningSideMapping;
|
||||
use Doctrine\ORM\Mapping\QuoteStrategy;
|
||||
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function explode;
|
||||
use function implode;
|
||||
|
||||
/**
|
||||
* Quote all identifiers to preserve camelCase column names in Postgres.
|
||||
*/
|
||||
final class AlwaysQuoteStrategy implements QuoteStrategy
|
||||
{
|
||||
use SQLResultCasing;
|
||||
|
||||
public function getColumnName(string $fieldName, ClassMetadata $class, AbstractPlatform $platform): string
|
||||
{
|
||||
return $platform->quoteSingleIdentifier($class->fieldMappings[$fieldName]->columnName);
|
||||
}
|
||||
|
||||
public function getTableName(ClassMetadata $class, AbstractPlatform $platform): string
|
||||
{
|
||||
$tableName = $platform->quoteSingleIdentifier($class->table['name']);
|
||||
|
||||
if (! empty($class->table['schema'])) {
|
||||
return $platform->quoteSingleIdentifier($class->table['schema']) . '.' . $tableName;
|
||||
}
|
||||
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
public function getSequenceName(array $definition, ClassMetadata $class, AbstractPlatform $platform): string
|
||||
{
|
||||
return implode('.', array_map(
|
||||
static fn (string $part) => $platform->quoteSingleIdentifier($part),
|
||||
explode('.', $definition['sequenceName']),
|
||||
));
|
||||
}
|
||||
|
||||
public function getJoinTableName(
|
||||
ManyToManyOwningSideMapping $association,
|
||||
ClassMetadata $class,
|
||||
AbstractPlatform $platform,
|
||||
): string {
|
||||
$schema = '';
|
||||
|
||||
if (isset($association->joinTable->schema)) {
|
||||
$schema = $platform->quoteSingleIdentifier($association->joinTable->schema) . '.';
|
||||
}
|
||||
|
||||
return $schema . $platform->quoteSingleIdentifier($association->joinTable->name);
|
||||
}
|
||||
|
||||
public function getJoinColumnName(JoinColumnMapping $joinColumn, ClassMetadata $class, AbstractPlatform $platform): string
|
||||
{
|
||||
return $platform->quoteSingleIdentifier($joinColumn->name);
|
||||
}
|
||||
|
||||
public function getReferencedJoinColumnName(
|
||||
JoinColumnMapping $joinColumn,
|
||||
ClassMetadata $class,
|
||||
AbstractPlatform $platform,
|
||||
): string {
|
||||
return $platform->quoteSingleIdentifier($joinColumn->referencedColumnName);
|
||||
}
|
||||
|
||||
public function getIdentifierColumnNames(ClassMetadata $class, AbstractPlatform $platform): array
|
||||
{
|
||||
$quotedColumnNames = [];
|
||||
|
||||
foreach ($class->identifier as $fieldName) {
|
||||
if (isset($class->fieldMappings[$fieldName])) {
|
||||
$quotedColumnNames[] = $this->getColumnName($fieldName, $class, $platform);
|
||||
continue;
|
||||
}
|
||||
|
||||
$assoc = $class->associationMappings[$fieldName];
|
||||
assert($assoc->isToOneOwningSide());
|
||||
$joinColumns = $assoc->joinColumns;
|
||||
$assocQuotedColumnNames = array_map(
|
||||
static fn (JoinColumnMapping $joinColumn) => $platform->quoteSingleIdentifier($joinColumn->name),
|
||||
$joinColumns,
|
||||
);
|
||||
|
||||
$quotedColumnNames = array_merge($quotedColumnNames, $assocQuotedColumnNames);
|
||||
}
|
||||
|
||||
return $quotedColumnNames;
|
||||
}
|
||||
|
||||
public function getColumnAlias(
|
||||
string $columnName,
|
||||
int $counter,
|
||||
AbstractPlatform $platform,
|
||||
ClassMetadata|null $class = null,
|
||||
): string {
|
||||
return $this->getSQLResultCasing($platform, $columnName . '_' . $counter);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use App\Enum\ModelCategory;
|
||||
use App\Repository\ModelTypeRepository;
|
||||
@@ -17,49 +19,57 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
#[ORM\Table(name: 'model_types')]
|
||||
#[ORM\UniqueConstraint(name: 'unique_category_name', columns: ['category', 'name'])]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['category' => 'exact'])]
|
||||
#[ApiResource]
|
||||
class ModelType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: Types::STRING, length: 36)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read'])]
|
||||
private ?string $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 120)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private string $name;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 60, unique: true)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private string $code;
|
||||
|
||||
#[ORM\Column(enumType: ModelCategory::class)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private ModelCategory $category;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private ?string $notes = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
#[Groups(['type_machine:read'])]
|
||||
#[Groups(['type_machine:read', 'model_type:read', 'model_type:write'])]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true, name: 'componentSkeleton')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private ?array $componentSkeleton = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true, name: 'pieceSkeleton')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private ?array $pieceSkeleton = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true, name: 'productSkeleton')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private ?array $productSkeleton = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private \DateTimeImmutable $createdAt;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')]
|
||||
#[Groups(['model_type:read'])]
|
||||
private \DateTimeImmutable $updatedAt;
|
||||
|
||||
private ?array $pendingStructure = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Composant>
|
||||
*/
|
||||
@@ -195,6 +205,11 @@ class ModelType
|
||||
{
|
||||
$this->category = $category;
|
||||
|
||||
if ($this->pendingStructure !== null) {
|
||||
$this->applyStructureForCategory($this->pendingStructure, $category);
|
||||
$this->pendingStructure = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -258,6 +273,50 @@ class ModelType
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['model_type:read'])]
|
||||
public function getStructure(): ?array
|
||||
{
|
||||
return match ($this->category) {
|
||||
ModelCategory::COMPONENT => $this->componentSkeleton,
|
||||
ModelCategory::PIECE => $this->pieceSkeleton,
|
||||
ModelCategory::PRODUCT => $this->productSkeleton,
|
||||
};
|
||||
}
|
||||
|
||||
#[Groups(['model_type:write'])]
|
||||
public function setStructure(?array $structure): static
|
||||
{
|
||||
if (!isset($this->category)) {
|
||||
$this->pendingStructure = $structure;
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->applyStructureForCategory($structure, $this->category);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function applyStructureForCategory(?array $structure, ModelCategory $category): void
|
||||
{
|
||||
if ($category === ModelCategory::COMPONENT) {
|
||||
$this->componentSkeleton = $structure;
|
||||
$this->pieceSkeleton = null;
|
||||
$this->productSkeleton = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($category === ModelCategory::PIECE) {
|
||||
$this->pieceSkeleton = $structure;
|
||||
$this->componentSkeleton = null;
|
||||
$this->productSkeleton = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->productSkeleton = $structure;
|
||||
$this->componentSkeleton = null;
|
||||
$this->pieceSkeleton = null;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
|
||||
@@ -45,17 +45,17 @@ class Profile implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[Groups(['profile:read', 'profile:write'])]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 100, name: 'firstName')]
|
||||
#[ORM\Column(type: 'string', length: 100, name: 'firstname')]
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['profile:read', 'profile:write'])]
|
||||
private string $firstName;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 100, name: 'lastName')]
|
||||
#[ORM\Column(type: 'string', length: 100, name: 'lastname')]
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['profile:read', 'profile:write'])]
|
||||
private string $lastName;
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => true], name: 'isActive')]
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => true], name: 'isactive')]
|
||||
#[Groups(['profile:read', 'profile:write'])]
|
||||
private bool $isActive = true;
|
||||
|
||||
@@ -73,11 +73,11 @@ class Profile implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[Groups(['profile:write'])]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable', name: 'createdAt')]
|
||||
#[ORM\Column(type: 'datetime_immutable', name: 'createdat')]
|
||||
#[Groups(['profile:read'])]
|
||||
private DateTimeImmutable $createdAt;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable', name: 'updatedAt')]
|
||||
#[ORM\Column(type: 'datetime_immutable', name: 'updatedat')]
|
||||
#[Groups(['profile:read'])]
|
||||
private DateTimeImmutable $updatedAt;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class TypeMachine
|
||||
#[Groups(['type_machine:read', 'type_machine:write'])]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: true, name: 'maintenanceFrequency')]
|
||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
|
||||
#[Groups(['type_machine:read', 'type_machine:write'])]
|
||||
private ?string $category = null;
|
||||
|
||||
@@ -58,11 +58,11 @@ class TypeMachine
|
||||
#[Groups(['type_machine:read', 'type_machine:write'])]
|
||||
private ?string $maintenanceFrequency = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true, name: 'criticalParts')]
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)]
|
||||
#[Groups(['type_machine:read', 'type_machine:write'])]
|
||||
private ?array $components = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true, name: 'machinePieces')]
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)]
|
||||
#[Groups(['type_machine:read', 'type_machine:write'])]
|
||||
private ?array $criticalParts = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user