私は取得していますエラー:Gedmoツリーある、getPathエラー:ノードは、このリポジトリ500内部サーバーエラーに関連していない - InvalidArgumentException
Node is not related to this repository
500 Internal Server Error - InvalidArgumentException
UPDATE 1:私は木repository with traitsまたはextend abstract repositoryエラーを設定した場合、それは問題ではありません。同じです。
UPDATE 2:フルスタックトレースhttp://pastebin.com/TtaJnyzf
私は私が選択したノードへのルートからのパスを取得する必要があり、データベースからツリー構造で出力するHTMLのツリーにしたいと、具体的。私が理解しているように、getPath()関数でそれが行われます。
私が使用しています:
- のSymfony v3.0.6を。
- 教義のv2.5.4
- StofDoctrineExtensionsBundle [1]ツリー構造を管理するために
。
私はSymfony.com [2]のドキュメントを使い、GitHub [3]、[4]、[5]、[6]のドキュメントを使用しました。
これまでのところ私は、データベース内のツリー構造を持っていると私は、このようにHTMLのツリーを取得:
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Category;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class TreeController extends Controller
{
/**
* @Route("/tree", name="tree")
*/
public function treeAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('AppBundle:Category');
$options = array(
'decorate' => true,
'rootOpen' => '<ul>',
'rootClose' => '</ul>',
'childOpen' => '<li>',
'childClose' => '</li>',
nodeDecorator' => function($node)
{
return '<a href="/some_path/...">'. $node['title'] .'</a>';
}
);
$htmlTree = $repo->childrenHierarchy(
null, /* starting from root nodes */
false, /* false: load all children, true: only direct */
$options
);
return $this->render('tree/tree_show.html.twig', array('project_tree' => $htmlTree));
}
}
私が選択した項目
にツリー要素のルートからのパスを表示するために2つの行を変更nodeDecorator' => function($node) use ($repo)
{
return '<a href="/project_path/'. implode('/', $repo->getPath($node)) .'">'. $node['title'] .'</a>';
}
[7]と[8]から分かるように、ルートから選択されたアイテムへの要素の配列を返す関数getPath()が存在します。
は私はこの問題は、このコードブロックにあるかもしれないと思う:
$repo->getPath($node)
- [1] GitHubの上stofDoctrineExtensionsBundle。
- [2] stofDoctrineExtensinsBundnle documentation on Symfony.com;
- [3] Gedmo Tree documentation on GitHub;
- [4] Gedmo Tree > Tree Entity example;
- [5] Gedmo Tree > Basic Usage Example;
- [6] Tree html output example;
- [7] NestedTreeRepository [8] NestedTreeRepositoryTraitはfunction "getPath()"を有するNestedTreeRepositoryTrait
- を使用します。
助言してください。 あなたの時間と知識をありがとうございます。
完全なスタックトレースを表示できますか? – xabbuh
@xabbuh私は自分の質問をスタックトレースで更新しました – Rikijs