src/Observers/GenericValidationObserver.php
/**
     * Process the observer's business logic.
     *
     * @return array The processed row
     */
Process the observer's business logic.
@return array The processed row
Process the observer ' s business logic . @return array The processed row
protected function process()
    {
        $headerNames = array_keys($this->getHeaders());
        $emptyValueDefinition = $this->getEmptyAttributeValueConstant();
        foreach ($headerNames as $headerName) {
            $attributeValue = $this->getValue($headerName);
            $columnName = $this->reverseMapHeaderNameToColumnName($headerName);
            $callbacks = $this->getCallbacksByType($columnName);
            foreach ($callbacks as $callback) {
                try {
                    if ($attributeValue === $emptyValueDefinition) {
                        continue;
                    }
                    $callback->handle($columnName, $attributeValue);
                } catch (\InvalidArgumentException $iea) {
                    $this->mergeStatus(
                        array(
                            RegistryKeys::VALIDATIONS => array(
                                basename($this->getFilename()) => array(
                                    $this->getSubject()->getLineNumber() => array(
                                        $columnName => $iea->getMessage()
                                    )
                                )
                            )
                        )
                    );
                }
            }
        }
    }
protected function process ( ) { $ headerNames = array_keys ( $ this -> getHeaders ( ) ) ; $ emptyValueDefinition = $ this -> getEmptyAttributeValueConstant ( ) ; foreach ( $ headerNames as $ headerName ) { $ attributeValue = $ this -> getValue ( $ headerName ) ; $ columnName = $ this -> reverseMapHeaderNameToColumnName ( $ headerName ) ; $ callbacks = $ this -> getCallbacksByType ( $ columnName ) ; foreach ( $ callbacks as $ callback ) { try { if ( $ attributeValue === $ emptyValueDefinition ) { continue ; } $ callback -> handle ( $ columnName , $ attributeValue ) ; } catch ( \ InvalidArgumentException $ iea ) { $ this -> mergeStatus ( array ( RegistryKeys :: VALIDATIONS => array ( basename ( $ this -> getFilename ( ) ) => array ( $ this -> getSubject ( ) -> getLineNumber ( ) => array ( $ columnName => $ iea -> getMessage ( ) ) ) ) ) ) ; } } } }
Process the observer's business logic.
Process the observer ' s business logic .
// load the available header names // iterate over the custom validations // load the attribute value from the row // reverse map the header name to the original column name // load the callbacks for the actual attribute code // invoke the registered callbacks // query whether or not to cleanup complete attribute // add the the validation result to the status