src/Observers/AdditionalAttributeObserver.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()
    {
        if ($additionalAttributes = $this->getValue(ColumnKeys::ADDITIONAL_ATTRIBUTES)) {
            $subject = $this->getSubject();
            $additionalAttributes = $this->serializer->denormalize($additionalAttributes, false);
            foreach ($additionalAttributes as $attributeCode => $optionValue) {
                if ($subject->hasHeader($attributeCode) === false) {
                    $subject->addHeader($attributeCode);
                }
                $this->setValue($attributeCode, $optionValue);
                if ($subject->isDebugMode()) {
                    $subject->getSystemLogger()->debug(
                        sprintf(
                            'Extract new column "%s" with value "%s" from column "%s" in file %s on line %d',
                            $attributeCode,
                            $optionValue,
                            ColumnKeys::ADDITIONAL_ATTRIBUTES,
                            $subject->getFilename(),
                            $subject->getLineNumber()
                        )
                    );
                }
            }
        }
    }
protected function process ( ) { if ( $ additionalAttributes = $ this -> getValue ( ColumnKeys :: ADDITIONAL_ATTRIBUTES ) ) { $ subject = $ this -> getSubject ( ) ; $ additionalAttributes = $ this -> serializer -> denormalize ( $ additionalAttributes , false ) ; foreach ( $ additionalAttributes as $ attributeCode => $ optionValue ) { if ( $ subject -> hasHeader ( $ attributeCode ) === false ) { $ subject -> addHeader ( $ attributeCode ) ; } $ this -> setValue ( $ attributeCode , $ optionValue ) ; if ( $ subject -> isDebugMode ( ) ) { $ subject -> getSystemLogger ( ) -> debug ( sprintf ( 'Extract new column "%s" with value "%s" from column "%s" in file %s on line %d' , $ attributeCode , $ optionValue , ColumnKeys :: ADDITIONAL_ATTRIBUTES , $ subject -> getFilename ( ) , $ subject -> getLineNumber ( ) ) ) ; } } } }
Process the observer's business logic.
Process the observer ' s business logic .
// query whether or not the row has additional attributes // load the subject instance // explode the additional attributes // iterate over the attributes and append them to the row // try to load the appropriate key for the value // append/replace the attribute value // add a log message in debug mod