public function detach(IEntity $entity) { if ($entity->isAttached()) { $entity->fireEvent('onDetach'); } }