/** * {@inheritDoc} */ public function validateEntity(EntityInterface $entity, ErrorStore $errorStore) { if (!$entity->getSite()) { $errorStore->addError('o:site', 'A page must belong to a site.'); } $slug = $entity->getSlug(); if (!is_string($slug) || $slug === '') { $errorStore->addError('o:slug', 'The slug cannot be empty.'); } if (preg_match('/[^a-zA-Z0-9-]/u', $slug)) { $errorStore->addError('o:slug', 'A slug can only contain letters, numbers, and hyphens.'); } if ($entity->getSite() && !$this->isUnique($entity, ['slug' => $slug, 'site' => $entity->getSite()])) { $errorStore->addError('o:slug', sprintf('The slug "%s" is already taken.', $slug)); } if (!$entity->getTitle()) { $errorStore->addError('o:title', 'A page must have a title.'); } }
/** * {@inheritDoc} */ public function validateEntity(EntityInterface $entity, ErrorStore $errorStore) { $slug = $entity->getSlug(); if (!is_string($slug) || $slug === '') { $errorStore->addError('o:slug', 'The slug cannot be empty.'); } if (preg_match('/[^a-zA-Z0-9-]/u', $slug)) { $errorStore->addError('o:slug', 'A slug can only contain letters, numbers, and hyphens.'); } if (!$this->isUnique($entity, ['slug' => $slug])) { $errorStore->addError('o:slug', sprintf('The slug "%s" is already taken.', $slug)); } if (false == $entity->getTitle()) { $errorStore->addError('o:title', 'A site must have a title.'); } if (false == $entity->getTheme()) { $errorStore->addError('o:theme', 'A site must have a theme.'); } $this->validateNavigation($entity, $errorStore); if (!is_array($entity->getItemPool())) { $errorStore->addError('o:item_pool', 'A site must have item pool data.'); } }