summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Mapping/Builder/EmbeddedBuilder.php
blob: b9d2127393b338d9a6f9b41a7310a4a8d5f42c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

declare(strict_types=1);

namespace Doctrine\ORM\Mapping\Builder;

/**
 * Embedded Builder
 *
 * @link        www.doctrine-project.com
 */
class EmbeddedBuilder
{
    /** @param mixed[] $mapping */
    public function __construct(
        private readonly ClassMetadataBuilder $builder,
        private array $mapping,
    ) {
    }

    /**
     * Sets the column prefix for all of the embedded columns.
     *
     * @return $this
     */
    public function setColumnPrefix(string $columnPrefix): static
    {
        $this->mapping['columnPrefix'] = $columnPrefix;

        return $this;
    }

    /**
     * Finalizes this embeddable and attach it to the ClassMetadata.
     *
     * Without this call an EmbeddedBuilder has no effect on the ClassMetadata.
     */
    public function build(): ClassMetadataBuilder
    {
        $cm = $this->builder->getClassMetadata();

        $cm->mapEmbedded($this->mapping);

        return $this->builder;
    }
}