src/Controller/Framework/DocTreeController.php
/**
     * @Route("/render/{id}.{_format}", methods={"GET"}, defaults={"_format"="html"}, name="doctree_render_document")
     * @Template()
     *
     * PW: this is similar to the renderDocument function in the Editor directory, but different enough that I think it deserves a separate controller/view
     */


this is similar to the renderDocument function in the Editor directory, but different enough that I think it deserves a separate controller/view
this is similar to the renderDocument function in the Editor directory but different enough that I think it deserves a separate controller / view
public function renderDocumentAction(LsDoc $lsDoc, $_format = 'html'): array
    {
        $repo = $this->getDoctrine()->getRepository(LsDoc::class);
        $items = $repo->findAllChildrenArray($lsDoc);
        $haveParents = $repo->findAllItemsWithParentsArray($lsDoc);
        $topChildren = $repo->findTopChildrenIds($lsDoc);
        $parentsElsewhere = [];
        $orphaned = $items;
        foreach ($haveParents as $child) {
            $id = $child['id'];
            if (!empty($orphaned[$id])) {
                unset($orphaned[$id]);
            }
        }
        foreach ($orphaned as $orphan) {
            foreach ($orphan['associations'] as $association) {
                if (LsAssociation::CHILD_OF === $association['type']) {
                    $parentsElsewhere[] = $orphan;
                    unset($orphaned[$orphan['id']]);
                }
            }
        }
        Compare::sortArrayByFields($orphaned, ['sequenceNumber', 'listEnumInSource', 'humanCodingScheme']);
        return [
            'topItemIds' => $topChildren,
            'lsDoc' => $lsDoc,
            'items' => $items,
            'parentsElsewhere' => $parentsElsewhere,
            'orphaned' => $orphaned,
        ];
    }
public function renderDocumentAction ( LsDoc $ lsDoc , $ _format = 'html' ) : array { $ repo = $ this -> getDoctrine ( ) -> getRepository ( LsDoc :: class ) ; $ items = $ repo -> findAllChildrenArray ( $ lsDoc ) ; $ haveParents = $ repo -> findAllItemsWithParentsArray ( $ lsDoc ) ; $ topChildren = $ repo -> findTopChildrenIds ( $ lsDoc ) ; $ parentsElsewhere = [ ] ; $ orphaned = $ items ; foreach ( $ haveParents as $ child ) { $ id = $ child [ 'id' ] ; if ( ! empty ( $ orphaned [ $ id ] ) ) { unset ( $ orphaned [ $ id ] ) ; } } foreach ( $ orphaned as $ orphan ) { foreach ( $ orphan [ 'associations' ] as $ association ) { if ( LsAssociation :: CHILD_OF === $ association [ 'type' ] ) { $ parentsElsewhere [ ] = $ orphan ; unset ( $ orphaned [ $ orphan [ 'id' ] ] ) ; } } } Compare :: sortArrayByFields ( $ orphaned , [ 'sequenceNumber' , 'listEnumInSource' , 'humanCodingScheme' ] ) ; return [ 'topItemIds' => $ topChildren , 'lsDoc' => $ lsDoc , 'items' => $ items , 'parentsElsewhere' => $ parentsElsewhere , 'orphaned' => $ orphaned , ] ; }
@Route("/render/{id}.
@Route ( " / render / { id } .
// Not an orphan