src/Pool.php
public function &scrap(EntityInterface &$instance, $force_delete = false)
    {
        if ($instance->isNew()) {
            throw new RuntimeException('Only objects that are saved to database can be modified');
        }

        $registered_type = $this->requireRegisteredType(get_class($instance));

        $instance_id = $instance->getId();
        $instance = $this->getProducerForRegisteredType($registered_type)->scrap($instance, $force_delete);

        if ($instance->isNew() && !empty($this->objects_pool[$registered_type][$instance_id])) {
            unset($this->objects_pool[$registered_type][$instance_id]);
        }

        return $instance;
    }
public function &scrap(EntityInterface &$instance, $force_delete = false)
    {
        if ($instance->isNew()) {
            throw new RuntimeException('Only objects that are saved to database can be modified');
        }

        $registered_type = $this->requireRegisteredType(get_class($instance));

        $instance_id = $instance->getId();
        $instance = $this->getProducerForRegisteredType($registered_type)->scrap($instance, $force_delete);

        if ($instance->isNew() && !empty($this->objects_pool[$registered_type][$instance_id])) {
            unset($this->objects_pool[$registered_type][$instance_id]);
        }

        return $instance;
    }
Scrap an instance (move it to trash, if object supports, or delete it).

@param  EntityInterface $instance
@param  bool            $force_delete
@return EntityInterface