{"id":18031646,"url":"https://github.com/becklyn/routetreebundle","last_synced_at":"2025-03-27T05:30:51.867Z","repository":{"id":11791465,"uuid":"14334392","full_name":"Becklyn/RouteTreeBundle","owner":"Becklyn","description":"Adds a simple implementation for an automatic generation of a page tree to build a menu ","archived":false,"fork":false,"pushed_at":"2023-01-13T08:41:31.000Z","size":242,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"2.x","last_synced_at":"2024-04-15T00:45:30.339Z","etag":null,"topics":["php","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Becklyn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2013-11-12T14:27:36.000Z","updated_at":"2022-02-17T15:07:36.000Z","dependencies_parsed_at":"2023-01-14T12:13:46.829Z","dependency_job_id":null,"html_url":"https://github.com/Becklyn/RouteTreeBundle","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FRouteTreeBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FRouteTreeBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FRouteTreeBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2FRouteTreeBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Becklyn","download_url":"https://codeload.github.com/Becklyn/RouteTreeBundle/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791327,"owners_count":20672664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","symfony","symfony-bundle"],"created_at":"2024-10-30T10:10:02.444Z","updated_at":"2025-03-27T05:30:51.213Z","avatar_url":"https://github.com/Becklyn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"BecklynRouteTreeBundle\n======================\n\nAdds a simple implementation for an automatic generation of a route tree to build a menu.\n\n\n\nInstallation\n------------\n\nInstall the bundle via [packagist](https://packagist.org/packages/becklyn/route-tree-bundle):\n\n```javascript\n    // ...\n    require: {\n        // ...\n        \"becklyn/route-tree-bundle\": \"^2.0\"\n    },\n    // ...\n```\n\nLoad the bundle in your `app/AppKernel.php`:\n\n```php\n    public function registerBundles()\n    {\n        $bundles = array(\n            // ...\n            new \\Becklyn\\RouteTreeBundle\\BecklynRouteTreeBundle(),\n        );\n        // ...\n    }\n```\n\n\n\nDefining The Route Tree Nodes\n-----------------------------\nYou add elements to the tree by setting the options of the routes:\n\n```yaml\nhomepage:\n    path: /\n\nmy_route:\n    path: /my_route\n    options:\n        tree:\n            parent: homepage\n            title:  \"My Route\"\n```\n\n\n\nPath Options\n------------\n\n```yaml\nroute:\n    # ...\n    options:\n        tree:\n            parent:     homepage       # the name of the parent node\n            priority:   0              # (optional) the \n            title:      \"abc\"          # (optional) title of the node\n            parameters: {}             # (optional) the default values for the parameters\n            security:   ~              # (optional) the security expression\n```\n\n`parent` must be set. Also all referenced `parent`-routes need to exist.\n\n\n### Priority\nAll child nodes of all nodes are sorted by descending priority.\n\n\n### Hidden\nAll items are automatically hidden, if they have no title set (or if the security expression evaluates to false).\n\n\n### Parameters\nThe parameters can define default values for parameters:\n\n```yml\npage_listing:\n    path: /listing/{page}\n    options:\n        tree:\n            parameters:\n                page: 1\n```\n\n**If you do not define a value, the parameter is looked up in the request attributes of the current request. If it doesn't find anything there, `1` is used.**\n\n\n### Security\nEvery node can have a custom security expression, that is evaluated when printing the tree.\nAll nodes where the security expression evaluates to `false` are automatically hidden (including all their child nodes).\n\nIf no explicit security expression is given, the builder tries to infer the expression from the linked controller by combining `@IsGranted()`\nand `@Security()` annotations from the action method and the controller class.\nIf `@IsGranted()` is used with the `subject` attribute, nothing is infered.\n\n\n### Extra Parameters\nYou can define additional parameters, that can be used in the menu template.\nAll path options that are not recognized (see \"Path Options\") are automatically added as extra parameters.\n\n```yaml\nroute:\n    options:\n        tree:\n            parent: homepage\n            title: Pages\n            icon: pages\n```\n\nThese extra parameters are available in the template under the `extra` property:\n\n```twig\n{{ item.extra(\"icon\") }}\n```\n\n\n### Error Cases\nIf the page tree is invalid a `InvalidRouteTreeException` is thrown, on the first construction of the page tree.\n\n\n\nShort Syntax\n------------\n\nIn simple cases, the config can be simplified to:\n\n\n```yaml\nroute:   \n    options:\n        tree: \"parent\"\n        \n# ... means the same as ...\n\nroute:   \n    options:\n        tree: \n            parent: \"parent\"\n```\n\n\n\nRendering the Route Tree\n------------------------\n\nThere is an automatic menu builder, that you can just use in the templates:\n\n```twig\n{{- route_tree_render(\"my_route\", {...}) -}}\n```\n\nThe first parameter is the parent node of which the menu should be used. The second (optional) argument are the [KnpMenu render options].\n\n\nGetting The Route Tree\n----------------------\nYou can inject the service `Becklyn\\RouteTreeBundle\\Tree\\RouteTree` and use it to retrieve a node:\n\n```php\n    // get a node with a specific route. With this node you can traverse the route tree.\n    $treeUnderMyRoute = $routeTree-\u003egetNode(\"my_route\");\n```\n\nThe return value is a `Becklyn\\RouteTreeBundle\\Node\\Node`.\n\n\n[KnpMenu render options]: https://github.com/KnpLabs/KnpMenu/blob/master/doc/01-Basic-Menus.markdown#other-rendering-options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Froutetreebundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbecklyn%2Froutetreebundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Froutetreebundle/lists"}