public function delete(EnvironmentInterface $environment, ModelIdInterface $modelId)
    {
        $this->guardNotEditOnly($environment->getDataDefinition(), $modelId);
        $this->guardIsDeletable($environment, $modelId);

        $model = $this->fetchModel($environment, $modelId);

        // Trigger event before the model will be deleted.
        $preDeleteEvent = new PreDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($preDeleteEvent::NAME, $preDeleteEvent);

        $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
        $dataProvider->delete($model);

        // Trigger event after the model is deleted.
        $postDeleteEvent = new PostDeleteModelEvent($environment, $model);
        $environment->getEventDispatcher()->dispatch($postDeleteEvent::NAME, $postDeleteEvent);
    }