Gedmo Tree getPath Error: Node is not related to this repository 500 Internal Server Error - InvalidArgumentException

后端 未结 1 1307
醉梦人生
醉梦人生 2021-01-28 09:57

I am getting error:

Node is not related to this repository
500 Internal Server Error - InvalidArgumentException

UPDATE 1: it does not matter if

相关标签:
1条回答
  • 2021-01-28 10:18

    Got it working!

    Here are the needed changes:

    instead of

    nodeDecorator' => function($node) use ($repo)
    {
        return '<a href="/project_path/'. implode('/', $repo->getPath($node)) .'">'. $node['title'] .'</a>';
    }
    

    one should write

    'nodeDecorator' => function($node) use ($repo)
    {
        return '<a href="/project_path/'. @implode('/', $repo->getPath($repo->findOneBy(array('id' => $node['id'])))) .'">'. $node['title'] .'</a>';
    }
    

    and in Category class add

    public function __toString()
    {
        return $this->getTitle();
    }
    

    That is it, path to each node now should be showing.

    0 讨论(0)
提交回复
热议问题