protected function scheduleRelationForInsertion($root, $child, $foreignKey)
    {
        if (!$this->entityRegistry->isRegistered($root)) {
            $this->scheduleForInsertion($root);
        }

        if (!$this->entityRegistry->isRegistered($child)) {
            $this->scheduleForInsertion($child);
        }

        $isAccessorRegistry = $this->entityRegistry->getIdAccessorRegistry();
        $this->entityRegistry->registerAggregateRootCallback(
            $root,
            $child,
            function ($root, $child) use ($foreignKey, $isAccessorRegistry) {
                $reflection = new \ReflectionProperty(get_class($child), $foreignKey);
                $reflection->setAccessible(true);
                $reflection->setValue($child, $isAccessorRegistry->getEntityId($root));
            }
        );
    }
protected function scheduleRelationForInsertion($root, $child, $foreignKey)
    {
        if (!$this->entityRegistry->isRegistered($root)) {
            $this->scheduleForInsertion($root);
        }

        if (!$this->entityRegistry->isRegistered($child)) {
            $this->scheduleForInsertion($child);
        }

        $isAccessorRegistry = $this->entityRegistry->getIdAccessorRegistry();
        $this->entityRegistry->registerAggregateRootCallback(
            $root,
            $child,
            function ($root, $child) use ($foreignKey, $isAccessorRegistry) {
                $reflection = new \ReflectionProperty(get_class($child), $foreignKey);
                $reflection->setAccessible(true);
                $reflection->setValue($child, $isAccessorRegistry->getEntityId($root));
            }
        );
    }
protected function scheduleRelationForInsertion ( $ root , $ child , $ foreignKey ) { if ( ! $ this -> entityRegistry -> isRegistered ( $ root ) ) { $ this -> scheduleForInsertion ( $ root ) ; } if ( ! $ this -> entityRegistry -> isRegistered ( $ child ) ) { $ this -> scheduleForInsertion ( $ child ) ; } $ isAccessorRegistry = $ this -> entityRegistry -> getIdAccessorRegistry ( ) ; $ this -> entityRegistry -> registerAggregateRootCallback ( $ root , $ child , function ( $ root , $ child ) use ( $ foreignKey , $ isAccessorRegistry ) { $ reflection = new \ ReflectionProperty ( get_class ( $ child ) , $ foreignKey ) ; $ reflection -> setAccessible ( true ) ; $ reflection -> setValue ( $ child , $ isAccessorRegistry -> getEntityId ( $ root ) ) ; } ) ; }
Schedules an entity for insertion creating an aggregate root callback

@param   object $root       The root object
@param   object $child      The child object (containing the foreign key)
@param   string $foreignKey The name of the foreign key property in the child object

@return  void
Schedules an entity for insertion creating an aggregate root callback