codeTemplates/src/Entity/Relations/TemplateEntity/Traits/HasTemplateEntities/HasTemplateEntitiesOneToMany.php
<?php declare(strict_types=1);
// phpcs:disable
namespace TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasTemplateEntities;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
use ReflectionException;
use TemplateNamespace\Entities\TemplateEntity as TemplateEntity;
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasTemplateEntitiesAbstract;
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\ReciprocatesTemplateEntity;
/**
* Trait HasTemplateEntitiesOneToMany
*
* One instance of the current Entity (that is using this trait)
* has Many instances (references) to TemplateEntity.
*
* The TemplateEntity has a corresponding ManyToOne relationship
* to the current Entity (that is using this trait)
*
* @package TemplateNamespace\Entities\Traits\Relations\TemplateEntity\HasTemplateEntities
*/
// phpcs:enable
trait HasTemplateEntitiesOneToMany
{
use HasTemplateEntitiesAbstract;
use ReciprocatesTemplateEntity;
/**
* @param ClassMetadataBuilder $builder
*
* @throws DoctrineStaticMetaException
* @throws ReflectionException
* @SuppressWarnings(PHPMD.StaticAccess)
*/
public static function metaForTemplateEntities(
ClassMetadataBuilder $builder
): void {
$builder->addOneToMany(
TemplateEntity::getDoctrineStaticMeta()->getPlural(),
TemplateEntity::class,
self::getDoctrineStaticMeta()->getSingular()
);
}
}