/** * {@inheritDoc} */ public function validateEntity(EntityInterface $entity, ErrorStore $errorStore) { // Validate local name if (false == $entity->getLocalName()) { $errorStore->addError('o:local_name', 'The local name cannot be empty.'); } // Validate label if (false == $entity->getLabel()) { $errorStore->addError('o:label', 'The label cannot be empty.'); } // Validate vocabulary if ($entity->getVocabulary() instanceof Vocabulary) { if ($entity->getVocabulary()->getId()) { // Vocabulary is persistent. Check for unique local name. $criteria = ['vocabulary' => $entity->getVocabulary(), 'localName' => $entity->getLocalName()]; if (!$this->isUnique($entity, $criteria)) { $errorStore->addError('o:local_name', sprintf('The local name "%s" is already taken.', $entity->getLocalName())); } } } else { $errorStore->addError('o:vocabulary', 'A vocabulary must be set.'); } }