public function getDataByItem(\core_kernel_classes_Resource $item)
    {
        foreach ($this->columns as $column => $config) {
            /** @var Extractor $extractor */
            $extractor = $this->extractors[$config['extractor']];
            if (isset($config['parameters'])) {
                $parameters = $config['parameters'];
            } else {
                $parameters = [];
            }
            $extractor->addColumn($column, $parameters);
        }

        $data = ['0' => []];
        foreach ($this->extractors as $extractor) {

            $extractor->setItem($item);
            $extractor->run();
            $values = $extractor->getData();

            foreach ($values as $key => $value) {

                $interactionData = is_array($value) && count($value) > 1 ? $value : $values;

                if (array_values(array_intersect(array_keys($data[0]), array_keys($interactionData))) == array_keys($interactionData)) {
                    $line = array_intersect_key($data[0], array_flip($this->headers));
                    $data[] = array_merge($line, $interactionData);
                } else {
                    $data[0] = array_merge($data[0], $interactionData);
                }

                $this->headers = array_unique(array_merge($this->headers, array_keys($interactionData)));
            }
        }

        return $data;
    }
public function getDataByItem(\core_kernel_classes_Resource $item)
    {
        foreach ($this->columns as $column => $config) {
            /** @var Extractor $extractor */
            $extractor = $this->extractors[$config['extractor']];
            if (isset($config['parameters'])) {
                $parameters = $config['parameters'];
            } else {
                $parameters = [];
            }
            $extractor->addColumn($column, $parameters);
        }

        $data = ['0' => []];
        foreach ($this->extractors as $extractor) {

            $extractor->setItem($item);
            $extractor->run();
            $values = $extractor->getData();

            foreach ($values as $key => $value) {

                $interactionData = is_array($value) && count($value) > 1 ? $value : $values;

                if (array_values(array_intersect(array_keys($data[0]), array_keys($interactionData))) == array_keys($interactionData)) {
                    $line = array_intersect_key($data[0], array_flip($this->headers));
                    $data[] = array_merge($line, $interactionData);
                } else {
                    $data[0] = array_merge($data[0], $interactionData);
                }

                $this->headers = array_unique(array_merge($this->headers, array_keys($interactionData)));
            }
        }

        return $data;
    }
public function getDataByItem ( \ core_kernel_classes_Resource $ item ) { foreach ( $ this -> columns as $ column => $ config ) { /** @var Extractor $extractor */ $ extractor = $ this -> extractors [ $ config [ 'extractor' ] ] ; if ( isset ( $ config [ 'parameters' ] ) ) { $ parameters = $ config [ 'parameters' ] ; } else { $ parameters = [ ] ; } $ extractor -> addColumn ( $ column , $ parameters ) ; } $ data = [ '0' => [ ] ] ; foreach ( $ this -> extractors as $ extractor ) { $ extractor -> setItem ( $ item ) ; $ extractor -> run ( ) ; $ values = $ extractor -> getData ( ) ; foreach ( $ values as $ key => $ value ) { $ interactionData = is_array ( $ value ) && count ( $ value ) > 1 ? $ value : $ values ; if ( array_values ( array_intersect ( array_keys ( $ data [ 0 ] ) , array_keys ( $ interactionData ) ) ) == array_keys ( $ interactionData ) ) { $ line = array_intersect_key ( $ data [ 0 ] , array_flip ( $ this -> headers ) ) ; $ data [ ] = array_merge ( $ line , $ interactionData ) ; } else { $ data [ 0 ] = array_merge ( $ data [ 0 ] , $ interactionData ) ; } $ this -> headers = array_unique ( array_merge ( $ this -> headers , array_keys ( $ interactionData ) ) ) ; } } return $ data ; }
Loop foreach columns and extract data thought extractors

@param \core_kernel_classes_Resource $item
@return array
Loop foreach columns and extract data thought extractors