AbstractFixture.php
private function fixtureObject(array $data): void
    {
        $obj = $this->createNewInstance($data);

        // Sometimes keys are specified in fixtures.
        // We must make sure Doctrine will force them to be saved.
        // Support for non-composite primary keys only.
        // /!\ Be careful, this will override the generator type for ALL objects of the same entity class!
        //     This means that it _may_ break objects for which ids are not provided in the fixtures.
        $metadata = $this->manager->getClassMetadata($this->getEntityClass());
        $primaryKey = $metadata->getIdentifierFieldNames();
        if (1 === \count($primaryKey) && isset($data[$primaryKey[0]])) {
            $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE);
            $metadata->setIdGenerator(new AssignedGenerator());
        }

        // And finally we persist the item
        $this->manager->persist($obj);

        // If we need to flush it, then we do it too.
        if (
            $this->numberOfIteratedObjects > 0
            && $this->flushEveryXIterations() > 0
            && $this->numberOfIteratedObjects % $this->flushEveryXIterations() === 0
        ) {
            $this->manager->flush();
            if ($this->clearEMOnFlush) {
                $this->manager->clear();
            }
        }

        // If we have to add a reference, we do it
        if ($prefix = $this->getReferencePrefix()) {
            $methodName = $this->getMethodNameForReference();

            $reference = null;

            if (method_exists($obj, $methodName)) {
                $reference = $obj->{$methodName}();
            } elseif (method_exists($obj, '__toString')) {
                $reference = (string) $obj;
            }

            if (!$reference) {
                throw new RuntimeException(sprintf(
                    'If you want to specify a reference with prefix "%s", method "%s" or "%s" must exist in the class, or you can override the "%s" method and add your own.',
                    $prefix, $methodName, '__toString()', 'getMethodNameForReference'
                ));
            }
            $this->addReference($prefix.$reference, $obj);
        }
    }
private function fixtureObject(array $data): void
    {
        $obj = $this->createNewInstance($data);

        // Sometimes keys are specified in fixtures.
        // We must make sure Doctrine will force them to be saved.
        // Support for non-composite primary keys only.
        // /!\ Be careful, this will override the generator type for ALL objects of the same entity class!
        //     This means that it _may_ break objects for which ids are not provided in the fixtures.
        $metadata = $this->manager->getClassMetadata($this->getEntityClass());
        $primaryKey = $metadata->getIdentifierFieldNames();
        if (1 === \count($primaryKey) && isset($data[$primaryKey[0]])) {
            $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE);
            $metadata->setIdGenerator(new AssignedGenerator());
        }

        // And finally we persist the item
        $this->manager->persist($obj);

        // If we need to flush it, then we do it too.
        if (
            $this->numberOfIteratedObjects > 0
            && $this->flushEveryXIterations() > 0
            && $this->numberOfIteratedObjects % $this->flushEveryXIterations() === 0
        ) {
            $this->manager->flush();
            if ($this->clearEMOnFlush) {
                $this->manager->clear();
            }
        }

        // If we have to add a reference, we do it
        if ($prefix = $this->getReferencePrefix()) {
            $methodName = $this->getMethodNameForReference();

            $reference = null;

            if (method_exists($obj, $methodName)) {
                $reference = $obj->{$methodName}();
            } elseif (method_exists($obj, '__toString')) {
                $reference = (string) $obj;
            }

            if (!$reference) {
                throw new RuntimeException(sprintf(
                    'If you want to specify a reference with prefix "%s", method "%s" or "%s" must exist in the class, or you can override the "%s" method and add your own.',
                    $prefix, $methodName, '__toString()', 'getMethodNameForReference'
                ));
            }
            $this->addReference($prefix.$reference, $obj);
        }
    }
private function fixtureObject ( array $ data ) : void { $ obj = $ this -> createNewInstance ( $ data ) ; // Sometimes keys are specified in fixtures. // We must make sure Doctrine will force them to be saved. // Support for non-composite primary keys only. // /!\ Be careful, this will override the generator type for ALL objects of the same entity class! //     This means that it _may_ break objects for which ids are not provided in the fixtures. $ metadata = $ this -> manager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; $ primaryKey = $ metadata -> getIdentifierFieldNames ( ) ; if ( 1 === \ count ( $ primaryKey ) && isset ( $ data [ $ primaryKey [ 0 ] ] ) ) { $ metadata -> setIdGeneratorType ( $ metadata :: GENERATOR_TYPE_NONE ) ; $ metadata -> setIdGenerator ( new AssignedGenerator ( ) ) ; } // And finally we persist the item $ this -> manager -> persist ( $ obj ) ; // If we need to flush it, then we do it too. if ( $ this -> numberOfIteratedObjects > 0 && $ this -> flushEveryXIterations ( ) > 0 && $ this -> numberOfIteratedObjects % $ this -> flushEveryXIterations ( ) === 0 ) { $ this -> manager -> flush ( ) ; if ( $ this -> clearEMOnFlush ) { $ this -> manager -> clear ( ) ; } } // If we have to add a reference, we do it if ( $ prefix = $ this -> getReferencePrefix ( ) ) { $ methodName = $ this -> getMethodNameForReference ( ) ; $ reference = null ; if ( method_exists ( $ obj , $ methodName ) ) { $ reference = $ obj -> { $ methodName } ( ) ; } elseif ( method_exists ( $ obj , '__toString' ) ) { $ reference = ( string ) $ obj ; } if ( ! $ reference ) { throw new RuntimeException ( sprintf ( 'If you want to specify a reference with prefix "%s", method "%s" or "%s" must exist in the class, or you can override the "%s" method and add your own.' , $ prefix , $ methodName , '__toString()' , 'getMethodNameForReference' ) ) ; } $ this -> addReference ( $ prefix . $ reference , $ obj ) ; } }
Creates the object and persist it in database.

@param object $data
Creates the object and persist it in database .