FactoryGirl\Provider\Doctrine\FixtureFactory::updateCollectionSideOfAssocation PHP Method

updateCollectionSideOfAssocation() protected method

protected updateCollectionSideOfAssocation ( $entityBeingCreated, $metadata, $fieldName, $value )
    protected function updateCollectionSideOfAssocation($entityBeingCreated, $metadata, $fieldName, $value)
    {
        $assoc = $metadata->getAssociationMapping($fieldName);
        $inverse = $assoc['inversedBy'];
        if ($inverse) {
            $valueMetadata = $this->em->getClassMetadata(get_class($value));
            $collection = $valueMetadata->getFieldValue($value, $inverse);
            if ($collection instanceof Collection) {
                $collection->add($entityBeingCreated);
            }
        }
    }