src/Listeners/ReduceAttributeOptionValueListener.php
/**
     * Handle the event.
     *
     * @param \League\Event\EventInterface $event The event that triggered the listener
     *
     * @return void
     */
Handle the event.
@param \League\Event\EventInterface $event The event that triggered the listener

@return void
Handle the event . @param \ League \ Event \ EventInterface $event The event that triggered the listener @return void
public function handle(EventInterface $event)
    {
        if ($artefacts = $this->registryProcessor->getAttribute(CacheKeys::ARTEFACTS)) {
            if (isset($artefacts[$this->getArtefactName()])) {
                $toExport = array();
                $arts = $artefacts[$this->getArtefactName()];
                foreach ($arts as $attributeOptionValues) {
                    foreach ($attributeOptionValues as $attributeOptionValue) {
                        $attributeCode = md5(\json_encode($attributeOptionValue));
                        if (isset($toExport[$attributeCode])) {
                            continue;
                        }
                        $toExport[$attributeCode] = $attributeOptionValue;
                    }
                }
                $artefacts[$this->getArtefactName()] = array($toExport);
                $this->registryProcessor->setAttribute(CacheKeys::ARTEFACTS, $artefacts, array(), array(), true);
            }
        }
    }
public function handle ( EventInterface $ event ) { if ( $ artefacts = $ this -> registryProcessor -> getAttribute ( CacheKeys :: ARTEFACTS ) ) { if ( isset ( $ artefacts [ $ this -> getArtefactName ( ) ] ) ) { $ toExport = array ( ) ; $ arts = $ artefacts [ $ this -> getArtefactName ( ) ] ; foreach ( $ arts as $ attributeOptionValues ) { foreach ( $ attributeOptionValues as $ attributeOptionValue ) { $ attributeCode = md5 ( \ json_encode ( $ attributeOptionValue ) ) ; if ( isset ( $ toExport [ $ attributeCode ] ) ) { continue ; } $ toExport [ $ attributeCode ] = $ attributeOptionValue ; } } $ artefacts [ $ this -> getArtefactName ( ) ] = array ( $ toExport ) ; $ this -> registryProcessor -> setAttribute ( CacheKeys :: ARTEFACTS , $ artefacts , array ( ) , array ( ) , true ) ; } } }
Handle the event.
Handle the event .
// try to load the availalbe artefacts from the registry processor // query whether or not categories are available // initialize the array for the sorted und merged categories // load the categories from the artefacts // iterate over the categories // Generate unique key for artefact to avoid duplicates // query whether or not the attribute code has already been processed // if not, add it to the array // replace them in the array with the artefacts // override the old artefacts