/** * @see Editor_Models_ConceptValidator::validate($concept) */ public function isValid(Editor_Models_Concept $concept, $extraData) { $this->_setField('status'); $isValid = true; if ($extraData['status'] == 'expired' && $concept->hasAnyRelations()) { $isValid = false; $this->_setErrorMessage(_('Can not change status to "expired" while there are still relations to other concepts.')); } else { // Check if there are any concepts in the relations which are expired. $allRelations = $concept->getAllRelationsAndMappings(); foreach ($allRelations as $relations) { if (!empty($relations)) { foreach ($relations as $relatedConcept) { if ($relatedConcept['status'] == 'expired') { $isValid = false; $relatedConcept = new Editor_Models_Concept($relatedConcept); $this->_addConflictedConcept($relatedConcept); } } } } if (!$isValid) { $this->_setErrorMessage(_('Can not relate the concept to any expired concepts. The fallowing concepts are expired:')); } } return $isValid; }