src/snac/server/validation/validators/IDValidator.php
/**
     * Validate a Name Entry
     *
     * @param \snac\data\NameEntry $nameEntry NameEntry to validate
     * @param mixed[] $context optional Any context information needed for validation
     * @return boolean true if valid, false otherwise
     */
Validate a Name Entry
@param \snac\data\NameEntry $nameEntry NameEntry to validate
@param mixed[] $context optional Any context information needed for validation
@return boolean true if valid, false otherwise
Validate a Name Entry @param \ snac \ data \ NameEntry $nameEntry NameEntry to validate @param mixed [] $context optional Any context information needed for validation @return boolean true if valid false otherwise
public function validateNameEntry($nameEntry, $context=null) {
        if ($nameEntry == null) {
            return true;
        }
        $success = true;
        if ($nameEntry->getID() == null) {
            $success = $success && $this->checkLanguage($nameEntry);
            $success = $success && $this->checkDates($nameEntry);
            $success = $success && $this->checkSCM($nameEntry);
            foreach($nameEntry->getContributors() as $contributor) {
                if ($contributor != null) {
                    if ($contributor->getID() != null) {
                        $this->addError("NameEntry without ID has Contributor with ID", $nameEntry);
                        $success = false;
                    } else {
                        $success = $success && $this->checkSCM($contributor);
                    }
                }
            }
            return $success;
        }
        if (isset($this->seen["nameEntry"]) && in_array($nameEntry->getID(), $this->seen["nameEntry"])) {
            $this->addError("ID used multiple times", $nameEntry);
            $success = false;
        }
        foreach ($this->constellation->getNameEntries() as $i => $current) {
            if ($nameEntry->getID() == $current->getID()) {
                if (!isset($this->seen["nameEntry"]))
                    $this->seen["nameEntry"] = array();
                array_push($this->seen["nameEntry"], $nameEntry->getID());
                $success = $success && $this->validateLanguage($nameEntry->getLanguage(), $current);
                $success = $success && $this->validateAllDates($nameEntry, $current);
                foreach ($nameEntry->getContributors() as $contributor) {
                    $success = $success && $this->validateContributor($contributor, $current);
                }
                $success = $success && $this->validateAllSCM($nameEntry, $current);
            }
        }
        return $success;
    }
public function validateNameEntry ( $ nameEntry , $ context = null ) { if ( $ nameEntry == null ) { return true ; } $ success = true ; if ( $ nameEntry -> getID ( ) == null ) { $ success = $ success && $ this -> checkLanguage ( $ nameEntry ) ; $ success = $ success && $ this -> checkDates ( $ nameEntry ) ; $ success = $ success && $ this -> checkSCM ( $ nameEntry ) ; foreach ( $ nameEntry -> getContributors ( ) as $ contributor ) { if ( $ contributor != null ) { if ( $ contributor -> getID ( ) != null ) { $ this -> addError ( " NameEntry without ID has Contributor with ID " , $ nameEntry ) ; $ success = false ; } else { $ success = $ success && $ this -> checkSCM ( $ contributor ) ; } } } return $ success ; } if ( isset ( $ this -> seen [ " nameEntry " ] ) && in_array ( $ nameEntry -> getID ( ) , $ this -> seen [ " nameEntry " ] ) ) { $ this -> addError ( " ID used multiple times " , $ nameEntry ) ; $ success = false ; } foreach ( $ this -> constellation -> getNameEntries ( ) as $ i => $ current ) { if ( $ nameEntry -> getID ( ) == $ current -> getID ( ) ) { if ( ! isset ( $ this -> seen [ " nameEntry " ] ) ) $ this -> seen [ " nameEntry " ] = array ( ) ; array_push ( $ this -> seen [ " nameEntry " ] , $ nameEntry -> getID ( ) ) ; $ success = $ success && $ this -> validateLanguage ( $ nameEntry -> getLanguage ( ) , $ current ) ; $ success = $ success && $ this -> validateAllDates ( $ nameEntry , $ current ) ; foreach ( $ nameEntry -> getContributors ( ) as $ contributor ) { $ success = $ success && $ this -> validateContributor ( $ contributor , $ current ) ; } $ success = $ success && $ this -> validateAllSCM ( $ nameEntry , $ current ) ; } } return $ success ; }
Validate a Name Entry
 @param \snac\data\NameEntry $nameEntry NameEntry to validate
 @param mixed[] $context optional Any context information needed for validation
 @return boolean true if valid, false otherwise
Validate a Name Entry @param \ snac \ data \ NameEntry $nameEntry NameEntry to validate @param mixed [] $context optional Any context information needed for validation @return boolean true if valid false otherwise
// If the nameEntry is null, stop and succeed (leaf node) // Set success to be true by default // If this nameEntry has no ID, but a subobject does, then success is false // If this nameEntry has already been seen, then success is false // Validate this nameEntry's ID against the real nameEntry from the database, and // validate all it's subelements against their counterparts from the database // Create the array if it doesn't exist yet // Add this name ID to the list of seen ids // Validate the subelements // Return success