protected function unloadDoctrineEntities()
    {
        $this->attributeKeysAndControllers = null;
        $app = Application::getFacadeApplication();
        $entityManager = $app->make(EntityManagerInterface::class);
        $entityManager->clear();
        $category = $this->getCategory();
        if ($category !== null) {
            $categoryClass = ClassUtils::getClass($category);
            if (!$entityManager->getMetadataFactory()->isTransient($categoryClass)) {
                $entityManager->merge($category);
            }
        }
    }