- Notice if some loop is nested too many times.
- Throwed whenever parent root entity of a relation not exists.
- An exception that's throwed when is not possibile to get the path.
- An exception that's throwed when entities path is requested too early.
- Build a map based on Doctrine's DataMapper.
- An interface to build maps of relations of database entities.
- Build the path of relations between entities.
use Mado\QueryBundle\Meta\DataMapper;
class MyCustomMapper implements DataMapper
{
public function getMap() : array
{
return [
"FooBundle\\Entity\\Start" => [
"relations" => [
"end" => "AppBundle\\Entity\\End",
"foo" => "AppBundle\\Entity\\Foo",
]
]
];
}
};
$finder = new JsonPathFinder(new MyCustomMapper($entityManager));
$finder->setQueryStartEntity("FooBundle\\Entity\\Start");
$finder->getPathToEntity("AppBundle\\Entity\\End"); // _embedded.start.end
- Navigate the graph to find the minimum spanning tree
$dijkstra = new Dijkstra(new MyCustomMapper($entityManager));
$entities = $dijkstra->shortestPaths($from, $to)
-
Use Dijkstra to find paths to use in querystring. For example to query all users with a group that is inside certain category with id 2, 3 or 5 we need this in query string.
filtering[_embedded.groups.category.id|list]=2,3,5
If we want to force this filter in queryBundle
$walker = new DijkstraWalker(
new \Mado\QueryBundle\Component\Meta\MapBuilder($manager)
new Dijkstra()
);
$walker->buildPathBetween(
\AppBundle\Entity\Start::class,
\FooBundle\Entity\End:class
);
$filter = $walker->getPath();
$repository = $this->getDoctrine()
->getRepository('AppBundle:User')
->setRequestWithFilter($request, [
$filter . '.id|list' => '2,3,5'
]);
- When a value is not a string, it comes from an additional filter. Additional filters should be stored as ...
{
"filter_name": {
"list" : [23, 666],
"entities" : [
{id:23,foo:"foo",bar:"bar"},
{id:666,foo:"foo",bar:"bar"},
]
},
"filter_name": {
"list" : [/* array of id */],
"entities" : [
// complete objects
]
}
}