src/Filter.php
public function getChildren($objects, $path)
    {
        $array = array();
        if (!is_array($path)) {
            $path = explode('/', $path);
        }
        if (!is_array($objects)) {
            $objects = array($objects);
        }

        $ret = $objects;

        foreach ($path as $child) { 
            $array = [];
            $meta = null;
            $properties = null;
            
            if ($ret && is_object(current($ret))) {
                $meta = $this->mapper->getMeta(get_class(current($ret)), !'strict');
                if ($meta) {
                    $properties = $meta->getProperties();
                }
            }

            foreach ($ret as $o) {
                $field = isset($properties[$child]) ? $properties[$child] : null;
                if (!$field || !isset($field['getter'])) {
                    $value = $o->{$child};
                } else {
                    $g = [$o, $field['getter']];
                    $value = $g();
                }
                
                if (is_array($value) || $value instanceof \Traversable) {
                    $array = array_merge($array, $value);
                }
                elseif ($value !== null) {
                    $array[] = $value;
                }
            }

            $ret = $array;
        }

        return $ret;
    }
public function getChildren($objects, $path)
    {
        $array = array();
        if (!is_array($path)) {
            $path = explode('/', $path);
        }
        if (!is_array($objects)) {
            $objects = array($objects);
        }

        $ret = $objects;

        foreach ($path as $child) { 
            $array = [];
            $meta = null;
            $properties = null;
            
            if ($ret && is_object(current($ret))) {
                $meta = $this->mapper->getMeta(get_class(current($ret)), !'strict');
                if ($meta) {
                    $properties = $meta->getProperties();
                }
            }

            foreach ($ret as $o) {
                $field = isset($properties[$child]) ? $properties[$child] : null;
                if (!$field || !isset($field['getter'])) {
                    $value = $o->{$child};
                } else {
                    $g = [$o, $field['getter']];
                    $value = $g();
                }
                
                if (is_array($value) || $value instanceof \Traversable) {
                    $array = array_merge($array, $value);
                }
                elseif ($value !== null) {
                    $array[] = $value;
                }
            }

            $ret = $array;
        }

        return $ret;
    }
public function getChildren ( $ objects , $ path ) { $ array = array ( ) ; if ( ! is_array ( $ path ) ) { $ path = explode ( '/' , $ path ) ; } if ( ! is_array ( $ objects ) ) { $ objects = array ( $ objects ) ; } $ ret = $ objects ; foreach ( $ path as $ child ) { $ array = [ ] ; $ meta = null ; $ properties = null ; if ( $ ret && is_object ( current ( $ ret ) ) ) { $ meta = $ this -> mapper -> getMeta ( get_class ( current ( $ ret ) ) , ! 'strict' ) ; if ( $ meta ) { $ properties = $ meta -> getProperties ( ) ; } } foreach ( $ ret as $ o ) { $ field = isset ( $ properties [ $ child ] ) ? $ properties [ $ child ] : null ; if ( ! $ field || ! isset ( $ field [ 'getter' ] ) ) { $ value = $ o -> { $ child } ; } else { $ g = [ $ o , $ field [ 'getter' ] ] ; $ value = $ g ( ) ; } if ( is_array ( $ value ) || $ value instanceof \ Traversable ) { $ array = array_merge ( $ array , $ value ) ; } elseif ( $ value !== null ) { $ array [ ] = $ value ; } } $ ret = $ array ; } return $ ret ; }
Retrieve all object child values through a property path.

Path can be an array:      ['prop', 'childProp', 'veryChildProp']
Or a '/' delimited string: prop/childProp/veryChildProp

@param object[] $objects
@param string|array $path
@return array
Retrieve all object child values through a property path .