src/Leevel/Database/Ddd/UnitOfWork.php
protected function handleRepository(): void
    {
        foreach (['Before', '', 'After'] as $position) {
            foreach (['creates', 'replaces', 'updates', 'deletes'] as $type) {
                $flag = $type.'Flag'.$position;

                if ($this->{$flag}) {
                    $flags = $this->{$flag};
                    asort($flags);

                    foreach ($flags as $id => $_) {
                        $entity = $this->{'entity'.ucfirst($type)}[$id];
                        $this->repository($entity)->{substr($type, 0, -1)}($entity);

                        if (isset($this->onCallbacks[$id])) {
                            foreach ($this->onCallbacks[$id] as $c) {
                                $c($entity, $this);
                            }
                        }

                        $this->entityStates[$id] = self::STATE_DETACHED;
                    }
                }
            }
        }

        $oldStates = $this->entityStates;
        $this->clear();
        $this->entityStates = $oldStates;
    }
protected function handleRepository(): void
    {
        foreach (['Before', '', 'After'] as $position) {
            foreach (['creates', 'replaces', 'updates', 'deletes'] as $type) {
                $flag = $type.'Flag'.$position;

                if ($this->{$flag}) {
                    $flags = $this->{$flag};
                    asort($flags);

                    foreach ($flags as $id => $_) {
                        $entity = $this->{'entity'.ucfirst($type)}[$id];
                        $this->repository($entity)->{substr($type, 0, -1)}($entity);

                        if (isset($this->onCallbacks[$id])) {
                            foreach ($this->onCallbacks[$id] as $c) {
                                $c($entity, $this);
                            }
                        }

                        $this->entityStates[$id] = self::STATE_DETACHED;
                    }
                }
            }
        }

        $oldStates = $this->entityStates;
        $this->clear();
        $this->entityStates = $oldStates;
    }
响应仓储.