This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » eZ Publish 5 Platform » Is there something like fetch/subtree...
expandshrink

Is there something like fetch/subtree in eZ5 / Symfony?

Is there something like fetch/subtree in eZ5 / Symfony?

Wednesday 22 January 2014 2:28:29 pm - 1 reply

Hello folks,

I am searching for a similar function like in ez4 fetch subtree.I have found two possible ways to do this but I hope there is a build in function for this.

First way:

Loading the legacy kernel in my controller and call fetch subtree from there

Second way:

I found a second possible way to do this in confluence.ez.no

 try
{
    // load the starting location and browse
    $location = $this->locationService->loadLocation( $locationId );
    $this->browseLocation( $location, $output );
}
catch ( \eZ\Publish\API\Repository\Exceptions\NotFoundException $e )
{
    $output->writeln( "<error>No location found with id $locationId</error>" );
}
catch( \eZ\Publish\API\Repository\Exceptions\UnauthorizedException $e )
{
    $output->writeln( "<error>Current users are not allowed to read location with id $locationId</error>" );
}
 
private function browseLocation( Location $location, OutputInterface $output, $depth = 0 )
{
    $childLocationList = $this->locationService->loadLocationChildren( $location, $offset = 0, $limit = -1 );
    // If offset and limit had been specified to something else then "all", then $childLocationList->totalCount contains the total count for iteration use
    foreach ( $childLocationList->locations as $childLocation )
    {
        $this->browseLocation( $childLocation, $output, $depth + 1 );
    }
}

 

But I still hope there is a way which is more easy to get the subtree of a location...Greetings, Timmy! \m/

Modified on Wednesday 22 January 2014 2:29:31 pm by Tim Heise

Wednesday 22 January 2014 4:44:14 pm

Hi

It seems like a good candidate for the SearchService happy.gif Emoticon

You also might want to take a look at Damien's slides from eZ Summer camp 2013 for a more practical example.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from