overallDefaultSystemConfigDeletion example

$salesChannelId = $event->getSalesChannelId();

        if (!\in_array($systemConfigKey, self::$defaultCmsPageConfigKeys, true)) {
            return;
        }

        // prevent deleting the overall default (salesChannelId === null)         // a sales channel specific default can still be deleted (salesChannelId !== null)         if ($newDefaultCmsPageId === null && $salesChannelId === null) {
            $oldCmsPageId = $this->getCurrentOverallDefaultCmsPageId($systemConfigKey);

            throw CmsException::overallDefaultSystemConfigDeletion($oldCmsPageId);
        }

        if (!\is_string($newDefaultCmsPageId) && $newDefaultCmsPageId !== null) {
            throw new PageNotFoundException('invalid page');
        }

        // prevent changing the default to an invalid cms page id         if (\is_string($newDefaultCmsPageId) && !$this->cmsPageExists($newDefaultCmsPageId)) {
            throw new PageNotFoundException($newDefaultCmsPageId);
        }
    }

    

    public static function exceptionDataProvider(): iterable
    {
        yield CmsException::DELETION_OF_DEFAULT_CODE => [
            'exception' => CmsException::deletionOfDefault(['id1', 'id2', 'id3']),
            'statusCode' => Response::HTTP_CONFLICT,
            'errorCode' => CmsException::DELETION_OF_DEFAULT_CODE,
            'message' => 'The cms pages with ids "id1, id2, id3" are assigned as a default and therefore can not be deleted.',
        ];

        yield CmsException::OVERALL_DEFAULT_SYSTEM_CONFIG_DELETION_CODE => [
            'exception' => CmsException::overallDefaultSystemConfigDeletion('cmsPageId'),
            'statusCode' => Response::HTTP_CONFLICT,
            'errorCode' => CmsException::OVERALL_DEFAULT_SYSTEM_CONFIG_DELETION_CODE,
            'message' => 'The cms page with id "cmsPageId" is assigned as a default to all sales channels and therefore can not be deleted.',
        ];
    }
}
Home | Imprint | This part of the site doesn't use cookies.