public function detach(IEntity $entity);
public function destroyAllEntities() { foreach ($this->entities as $entity) { if ($entity) { $this->repository->detach($entity); $entity->fireEvent('onFree'); } } $this->entities = []; }