src/Observers/EntityMergers/CleanUpColumnsEntityMerger.php
/**
     * Merge's and return's the entity with the passed attributes.
     *
     * @param \TechDivision\Import\Observers\ObserverInterface $observer The observer instance to detect the state for
     * @param array                                            $entity   The entity loaded from the database
     * @param array                                            $attr     The entity data from the import file
     *
     * @return array The entity attributes that has to be merged
     */
Merge's and return's the entity with the passed attributes.
@param \TechDivision\Import\Observers\ObserverInterface $observer The observer instance to detect the state for
@param array                                            $entity   The entity loaded from the database
@param array                                            $attr     The entity data from the import file

@return array The entity attributes that has to be merged
Merge ' s and return ' s the entity with the passed attributes . @param \ TechDivision \ Import \ Observers \ ObserverInterface $observer The observer instance to detect the state for @param array $entity The entity loaded from the database @param array $attr The entity data from the import file @return array The entity attributes that has to be merged
public function merge(ObserverInterface $observer, array $entity, array $attr) : array
    {
        if (($subject = $observer->getSubject()) instanceof CleanUpColumnsSubjectInterface) {
            $cleanUpColumns =  $subject->getCleanUpColumns();
            $columnNames = array_keys($attr);
            foreach ($columnNames as $columnName) {
                if ($observer->hasValue(isset($this->reverseHeaderMappings[$columnName]) ? $this->reverseHeaderMappings[$columnName] : $columnName) ||
                    in_array($columnName, $cleanUpColumns) ||
                    $columnName === EntityStatus::MEMBER_NAME
                ) {
                    continue;
                }
                unset($attr[$columnName]);
            }
        }
        return $attr;
    }
public function merge ( ObserverInterface $ observer , array $ entity , array $ attr ) : array { if ( ( $ subject = $ observer -> getSubject ( ) ) instanceof CleanUpColumnsSubjectInterface ) { $ cleanUpColumns = $ subject -> getCleanUpColumns ( ) ; $ columnNames = array_keys ( $ attr ) ; foreach ( $ columnNames as $ columnName ) { if ( $ observer -> hasValue ( isset ( $ this -> reverseHeaderMappings [ $ columnName ] ) ? $ this -> reverseHeaderMappings [ $ columnName ] : $ columnName ) || in_array ( $ columnName , $ cleanUpColumns ) || $ columnName === EntityStatus :: MEMBER_NAME ) { continue ; } unset ( $ attr [ $ columnName ] ) ; } } return $ attr ; }
Merge's and return's the entity with the passed attributes.
Merge ' s and return ' s the entity with the passed attributes .
// query whether or not the subject has columns that has to be cleaned-up // load the columns that has to be cleaned-up // load the column/member names from the attributes // iterate over the column names // we do NOT clean-up column names that has to be cleaned-up // unset the column, because it has NOT been cleaned-up // return the processed attributes