/**
  * {@inheritDoc}
  */
 public function validateEntity(EntityInterface $entity, ErrorStore $errorStore)
 {
     $label = $entity->getLabel();
     if (false == trim($label)) {
         $errorStore->addError('o:label', 'The label cannot be empty.');
     }
     if (!$this->isUnique($entity, ['label' => $label])) {
         $errorStore->addError('o:label', 'The label is already taken.');
     }
 }
Exemple #2
0
 /**
  * {@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.');
     }
 }