codeTemplates/src/Entity/Relations/TemplateEntity/Traits/HasRequiredTemplateEntities/HasRequiredTemplateEntitiesOneToMany.php
<?php declare(strict_types=1);
// phpcs:disable
namespace TemplateNamespace\Entity\Relations\TemplateEntity\Traits\HasRequiredTemplateEntities;
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\HasRequiredTemplateEntitiesAbstract;
use TemplateNamespace\Entity\Relations\TemplateEntity\Traits\ReciprocatesTemplateEntity;
/**
* Trait HasRequiredTemplateEntitiesOneToMany
*
* 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\HasRequiredTemplateEntities
*/
// phpcs:enable
trait HasRequiredTemplateEntitiesOneToMany
{
use HasRequiredTemplateEntitiesAbstract;
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()
);
}
}