code: public function preRemove($object)
      {
          if (!is_null($this->urlProvider) && !is_null($this->menuManager)) {
              $url      = $this->urlProvider->url($object);
              $menuItem = $this->menuManager->getItem($url);
  
              if ($menuItem instanceof MenuItem) {
                  $this->menuManager->removeItem($menuItem);
                  $this->menuManager->flush();
              }
          }
      }
docs: Pre remove function
  
  @param mixed $object