cmsPageIsDefault example


    public function beforeDeletion(EntityDeleteEvent $event): void
    {
        /** @var array<string> $cmsPageIds */
        $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 */
    
Home | Imprint | This part of the site doesn't use cookies.