Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@

final class EmbeddableClassAttributeTransformer implements ClassAttributeTransformerInterface
{
public function transform(EntityMapping $entityMapping, Class_ $class): void
public function transform(EntityMapping $entityMapping, Class_ $class): bool
{
$classMapping = $entityMapping->getClassMapping();

$type = $classMapping['type'] ?? null;
if ($type !== 'embeddable') {
return;
return false;
}

$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName());
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ final class EntityClassAttributeTransformer implements ClassAttributeTransformer
*/
private const REPOSITORY_CLASS_KEY = 'repositoryClass';

public function transform(EntityMapping $entityMapping, Class_ $class): void
public function transform(EntityMapping $entityMapping, Class_ $class): bool
{
$classMapping = $entityMapping->getClassMapping();

$type = $classMapping['type'] ?? null;
if ($type !== 'entity') {
return;
return false;
}

$args = [];
Expand All @@ -37,6 +37,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
}

$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Class_ $class): void
public function transform(EntityMapping $entityMapping, Class_ $class): bool
{
$classMapping = $entityMapping->getClassMapping();

$inheritanceType = $classMapping['inheritanceType'] ?? null;
if ($inheritanceType === null) {
return;
return false;
}

$class->attrGroups[] = AttributeFactory::createGroup(MappingClass::INHERITANCE_TYPE, [$inheritanceType]);
Expand All @@ -45,6 +45,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
if (isset($classMapping['discriminatorMap'])) {
$this->addDiscriminatorMap($classMapping['discriminatorMap'], $class);
}
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Class_ $class): void
public function transform(EntityMapping $entityMapping, Class_ $class): bool
{
$classMapping = $entityMapping->getClassMapping();

$softDeletableMapping = $classMapping['gedmo']['soft_deleteable'] ?? null;
if (! is_array($softDeletableMapping)) {
return;
return false;
}

$args = $this->nodeFactory->createArgs($softDeletableMapping);
Expand All @@ -40,6 +40,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void
}

$class->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Class_ $class): void
public function transform(EntityMapping $entityMapping, Class_ $class): bool
{
$classMapping = $entityMapping->getClassMapping();

$table = $classMapping[self::TABLE_KEY] ?? null;
if (isset($classMapping['type']) && $classMapping['type'] !== 'entity') {
return;
return false;
}

$args = [];
Expand All @@ -42,6 +42,7 @@ public function transform(EntityMapping $entityMapping, Class_ $class): void

$this->addIndexes($classMapping['indexes'] ?? [], $class, MappingClass::INDEX);
$this->addIndexes($classMapping['uniqueConstraints'] ?? [], $class, MappingClass::UNIQUE_CONSTRAINT);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$propertyMapping = $entityMapping->matchFieldPropertyMapping($property);
if ($propertyMapping === null) {
return;
return false;
}

// handled in another mapper
Expand All @@ -42,6 +42,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property

$args = array_merge($args, $this->nodeFactory->createArgs($propertyMapping));
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$propertyMapping = $entityMapping->matchEmbeddedPropertyMapping($property);
if ($propertyMapping === null) {
return;
return false;
}

// handled in another attribute
Expand All @@ -34,6 +34,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);

NodeValueNormalizer::ensureKeyIsClassConstFetch($args, 'class');
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$fieldPropertyMapping = $entityMapping->matchFieldPropertyMapping($property);

$timestampableMapping = $fieldPropertyMapping['gedmo']['timestampable'] ?? null;
if (! is_array($timestampableMapping)) {
return;
return false;
}

$args = $this->nodeFactory->createArgs($timestampableMapping);
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@

final class IdAttributeTransformer implements PropertyAttributeTransformerInterface
{
public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$idMapping = $entityMapping->matchIdPropertyMapping($property);
if (! is_array($idMapping)) {
return;
return false;
}

$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName());
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

final class IdColumnAttributeTransformer implements PropertyAttributeTransformerInterface
{
public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$idMapping = $entityMapping->matchIdPropertyMapping($property);
if (! is_array($idMapping)) {
return;
return false;
}

$args = [];
Expand All @@ -28,6 +28,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
}

$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$idMapping = $entityMapping->matchIdPropertyMapping($property);
if (! is_array($idMapping)) {
return;
return false;
}

$generator = $idMapping[EntityMappingKey::GENERATOR] ?? null;
if (! is_array($generator)) {
return;
return false;
}

// make sure strategy is uppercase as constant value
$generator = $this->normalizeStrategy($generator);

$args = $this->nodeFactory->createArgs($generator);
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$joinTableMapping = $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null;
if (! is_array($joinTableMapping)) {
return;
return false;
}

$joinColumns = $joinTableMapping['inverseJoinColumns'] ?? null;
if (! is_array($joinColumns)) {
return;
return false;
}

foreach ($joinColumns as $columnName => $joinColumn) {
$property->attrGroups[] = $this->createInverseJoinColumnAttrGroup($columnName, $joinColumn);
}
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$this->transformMapping(
$hasChangedManyToMany = $this->transformMapping(
$property,
$entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null
);
$this->transformMapping($property, $entityMapping->matchManyToOnePropertyMapping($property));
$hasChangedManyToOne = $this->transformMapping(
$property,
$entityMapping->matchManyToOnePropertyMapping($property)
);
return $hasChangedManyToMany || $hasChangedManyToOne;
}

public function getClassName(): string
Expand All @@ -37,10 +41,10 @@ public function getClassName(): string
/**
* @param array<string, array<string, mixed>>|null $mapping
*/
private function transformMapping(Property|Param $property, ?array $mapping): void
private function transformMapping(Property|Param $property, ?array $mapping): bool
{
if (! is_array($mapping)) {
return;
return false;
}

$singleJoinColumn = $mapping['joinColumn'] ?? null;
Expand All @@ -52,12 +56,15 @@ private function transformMapping(Property|Param $property, ?array $mapping): vo

$joinColumns = $mapping['joinColumns'] ?? null;
if (! is_array($joinColumns)) {
return;
return false;
}

$hasChanged = false;
foreach ($joinColumns as $columnName => $joinColumn) {
$hasChanged = true;
$property->attrGroups[] = $this->createJoinColumnAttrGroup($columnName, $joinColumn);
}
return $hasChanged;
}

private function createJoinColumnAttrGroup(int|string $columnName, mixed $joinColumn): AttributeGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$joinTableMapping = $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null;
if (! is_array($joinTableMapping)) {
return;
return false;
}

// handled by another mapper
Expand All @@ -35,6 +35,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);

NodeValueNormalizer::ensureKeyIsClassConstFetch($args, EntityMappingKey::TARGET_ENTITY);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$manyToManyMapping = $entityMapping->matchManyToManyPropertyMapping($property);
if (! is_array($manyToManyMapping)) {
return;
return false;
}

// handled by another mapper
Expand All @@ -35,6 +35,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);

NodeValueNormalizer::ensureKeyIsClassConstFetch($args, EntityMappingKey::TARGET_ENTITY);
return true;
}

public function getClassName(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public function __construct(
) {
}

public function transform(EntityMapping $entityMapping, Property|Param $property): void
public function transform(EntityMapping $entityMapping, Property|Param $property): bool
{
$manyToOneMapping = $entityMapping->matchManyToOnePropertyMapping($property);
if (! is_array($manyToOneMapping)) {
return;
return false;
}

// handled by another mapper
Expand All @@ -38,6 +38,7 @@ public function transform(EntityMapping $entityMapping, Property|Param $property
$property->attrGroups[] = AttributeFactory::createGroup($this->getClassName(), $args);

NodeValueNormalizer::ensureKeyIsClassConstFetch($args, EntityMappingKey::TARGET_ENTITY);
return true;
}

public function getClassName(): string
Expand Down
Loading
Loading