4

I'm using Tree - Nestedset behavior extension for Doctrine 2 and Closure Table Strategy. On my web, users can create folders and subfolders and view them. I implemented this by using Closure Table strategy and I render folders with childrenHierarchy() method:

       $directoryTree = $repository->childrenHierarchy(
            null,  
            true,  
            array(
        'decorate' => false,
        'childSort' => array('field' => 'directory_name', 'dir' => 'asc')
    ));

It works fine, but it returns all folders for all users and I don't know how to define user_id in this case to render only folders, that belong to login user. Is there any way to do this?

I will glad for your answers.

Olga Budnik
  • 1,143
  • 2
  • 8
  • 10

1 Answers1

3

From the doc:

childrenHierarchy: This useful method allows you to build an array of nodes representing the hierarchy of a tree. Arguments: node: If you pass a node, the method will return its children. Defaults to "null" (this means it will return ALL nodes).

would be something like this:

// example, 
$loggedInUserFolder = SOME_METHOD_RETURNS_USER_FOLDER($this->getUser());
$directoryTree = $repository->childrenHierarchy(
            $loggedInUserFolder,  
            true,  
            array(
        'decorate' => false,
        'childSort' => array('field' => 'directory_name', 'dir' => 'asc')
    ));
xurshid29
  • 4,172
  • 1
  • 20
  • 25