public function findDescendants($parent, $draft = true)
    {
        $this->setDraftVersionFilter(! $draft);
        
        $iterator = new \RecursiveIteratorIterator(
            new RecursiveBlockIterator([$parent]),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $blocks = [];
        foreach ($iterator as $descendant) {
            $blocks[] = $descendant;
        }

        if ($draft) {
            $this->revertToDraft($blocks);
        }

        return $blocks;
    }
public function findDescendants($parent, $draft = true)
    {
        $this->setDraftVersionFilter(! $draft);
        
        $iterator = new \RecursiveIteratorIterator(
            new RecursiveBlockIterator([$parent]),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $blocks = [];
        foreach ($iterator as $descendant) {
            $blocks[] = $descendant;
        }

        if ($draft) {
            $this->revertToDraft($blocks);
        }

        return $blocks;
    }
public function findDescendants ( $ parent , $ draft = true ) { $ this -> setDraftVersionFilter ( ! $ draft ) ; $ iterator = new \ RecursiveIteratorIterator ( new RecursiveBlockIterator ( [ $ parent ] ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ blocks = [ ] ; foreach ( $ iterator as $ descendant ) { $ blocks [ ] = $ descendant ; } if ( $ draft ) { $ this -> revertToDraft ( $ blocks ) ; } return $ blocks ; }
Finds the block and all its children recursively

@param BlockInterface $parent
@param bool $draft
@return BlockInterface[]
Finds the block and all its children recursively