src/Controller/Plugin/EntityEraser.php
public function erase(EntityInterface $entity)
    {
        $dependencies = $this->triggerEvent(DependencyResultEvent::DELETE, $entity);

        foreach ($dependencies as $result) {
            if ($result->isDelete()) {
                foreach ($result->getEntities() as $dependendEntity) {
                    $this->repositories->remove($dependendEntity);
                }
            }
        }

        $this->repositories->remove($entity);

        return $dependencies;
    }
public function erase(EntityInterface $entity)
    {
        $dependencies = $this->triggerEvent(DependencyResultEvent::DELETE, $entity);

        foreach ($dependencies as $result) {
            if ($result->isDelete()) {
                foreach ($result->getEntities() as $dependendEntity) {
                    $this->repositories->remove($dependendEntity);
                }
            }
        }

        $this->repositories->remove($entity);

        return $dependencies;
    }
Deletes an entity.

Triggers the DependencyResultEvent::DELETE event on the
"Core/EntityEraser/Dependencies/Events" event manager.

Removes the entity from the database.

@param EntityInterface $entity

@return \Core\Service\EntityEraser\DependencyResultCollection
@uses triggerEvent