deletionOfDefault example

 finally {
            static::assertTrue($exceptionWasThrown, 'Excepted exception with error code ' . $errorCode . ' to be thrown.');
        }
    }

    /** * @return array<string, array{exception: CmsException, statusCode: int, errorCode: string, message: string}> */
    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.',
        ];
    }
$cmsPageIds = $event->getIds(CmsPageDefinition::ENTITY_NAME);

        // no cms page is affected by this deletion event         if (empty($cmsPageIds)) {
            return;
        }

        $defaultPages = $this->cmsPageIsDefault($cmsPageIds);

        // count !== 0 indicates that there are some cms pages which would be deleted but are currently a default         if (\count($defaultPages) !== 0) {
            throw CmsException::deletionOfDefault($defaultPages);
        }
    }

    /** * @throws CmsException * @throws PageNotFoundException */
    public function validateChangeOfDefaultCmsPage(BeforeSystemConfigChangedEvent $event): void
    {
        $newDefaultCmsPageId = $event->getValue();
        $systemConfigKey = $event->getKey();
        
Home | Imprint | This part of the site doesn't use cookies.