Code Duplication    Length = 3-5 lines in 7 locations

lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php 1 location

@@ 459-461 (lines=3) @@
456
        }
457
458
        // Invoke the postLoad lifecycle callbacks and listeners
459
        if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) {
460
            $metadata->invokeLifecycleCallbacks(Events::postLoad, $document, array(new LifecycleEventArgs($document, $this->dm)));
461
        }
462
        if ($this->evm->hasListeners(Events::postLoad)) {
463
            $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm));
464
        }

lib/Doctrine/ODM/MongoDB/UnitOfWork.php 6 locations

@@ 680-682 (lines=3) @@
677
        }
678
679
        // Fire PreFlush lifecycle callbacks
680
        if ( ! empty($class->lifecycleCallbacks[Events::preFlush])) {
681
            $class->invokeLifecycleCallbacks(Events::preFlush, $document, array(new Event\PreFlushEventArgs($this->dm)));
682
        }
683
684
        $this->computeOrRecomputeChangeSet($class, $document);
685
    }
@@ 1062-1064 (lines=3) @@
1059
    private function persistNew(ClassMetadata $class, $document)
1060
    {
1061
        $oid = spl_object_hash($document);
1062
        if ( ! empty($class->lifecycleCallbacks[Events::prePersist])) {
1063
            $class->invokeLifecycleCallbacks(Events::prePersist, $document, array(new LifecycleEventArgs($document, $this->dm)));
1064
        }
1065
        if ($this->evm->hasListeners(Events::prePersist)) {
1066
            $this->evm->dispatchEvent(Events::prePersist, new LifecycleEventArgs($document, $this->dm));
1067
        }
@@ 1142-1144 (lines=3) @@
1139
                    $embeddedClass = $this->dm->getClassMetadata(get_class($embeddedDocument));
1140
                }
1141
1142
                if ( ! empty($embeddedClass->lifecycleCallbacks[Events::postPersist])) {
1143
                    $embeddedClass->invokeLifecycleCallbacks(Events::postPersist, $embeddedDocument, array(new LifecycleEventArgs($document, $this->dm)));
1144
                }
1145
                if ($hasPostPersistListeners) {
1146
                    $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($embeddedDocument, $this->dm));
1147
                }
@@ 1357-1361 (lines=5) @@
1354
                }
1355
1356
                if (isset($this->documentInsertions[$entryOid])) {
1357
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postPersist])) {
1358
                        $entryClass->invokeLifecycleCallbacks(Events::postPersist, $entry, array(
1359
                            new LifecycleEventArgs($entry, $this->dm)
1360
                        ));
1361
                    }
1362
                    if ($hasPostPersistListeners) {
1363
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1364
                    }
@@ 1366-1370 (lines=5) @@
1363
                        $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($entry, $this->dm));
1364
                    }
1365
                } else {
1366
                    if ( ! empty($entryClass->lifecycleCallbacks[Events::postUpdate])) {
1367
                        $entryClass->invokeLifecycleCallbacks(Events::postUpdate, $entry, array(
1368
                            new LifecycleEventArgs($entry, $this->dm)
1369
                        ));
1370
                    }
1371
                    if ($hasPostUpdateListeners) {
1372
                        $this->evm->dispatchEvent(Events::postUpdate, new LifecycleEventArgs($entry, $this->dm));
1373
                    }
@@ 1961-1963 (lines=3) @@
1958
                // nothing to do
1959
                break;
1960
            case self::STATE_MANAGED:
1961
                if ( ! empty($class->lifecycleCallbacks[Events::preRemove])) {
1962
                    $class->invokeLifecycleCallbacks(Events::preRemove, $document, array(new LifecycleEventArgs($document, $this->dm)));
1963
                }
1964
                if ($this->evm->hasListeners(Events::preRemove)) {
1965
                    $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
1966
                }