{"id":19861263,"url":"https://github.com/rybakit/rybakitnavigationbundle","last_synced_at":"2025-05-02T04:30:33.061Z","repository":{"id":3681665,"uuid":"4751508","full_name":"rybakit/RybakitNavigationBundle","owner":"rybakit","description":"Navigation bundle for Symfony applications.","archived":false,"fork":false,"pushed_at":"2018-01-11T13:25:13.000Z","size":132,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T03:02:04.430Z","etag":null,"topics":["bundle","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rybakit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-22T13:43:47.000Z","updated_at":"2020-05-02T23:39:43.000Z","dependencies_parsed_at":"2022-09-01T06:23:14.676Z","dependency_job_id":null,"html_url":"https://github.com/rybakit/RybakitNavigationBundle","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybakit%2FRybakitNavigationBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybakit%2FRybakitNavigationBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybakit%2FRybakitNavigationBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybakit%2FRybakitNavigationBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rybakit","download_url":"https://codeload.github.com/rybakit/RybakitNavigationBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251986651,"owners_count":21675950,"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":["bundle","php","symfony","symfony-bundle"],"created_at":"2024-11-12T15:08:30.636Z","updated_at":"2025-05-02T04:30:32.623Z","avatar_url":"https://github.com/rybakit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"RybakitNavigationBundle\n=======================\n[![Build Status](https://travis-ci.org/rybakit/RybakitNavigationBundle.svg?branch=master)](https://travis-ci.org/rybakit/RybakitNavigationBundle)\n\n## Installation\n\nThe recommended way to install this bundle is through [Composer](http://getcomposer.org):\n\n```sh\n$ composer require rybakit/navigation-bundle:~1.0@dev\n```\n\nAfter you have installed the package, include RybakitNavigationBundle to your kernel class:\n\n```php\npublic function registerBundles()\n{\n    $bundles = [\n        ...\n        new Rybakit\\Bundle\\RybakitNavigationBundle(),\n    ];\n\n    ...\n}\n```\n\n## Usage Examples\n\n\u003e To see how to create a menu as a service and retrieve it from different parts of your application, follow the link: https://gist.github.com/rybakit/4491556.\n\n### Build a navigation tree\n\n``` php\n\u003c?php\n\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Item;\n\n$root = new Item('root');\n$child = new Item('child');\n$root-\u003eadd($child);\n\n$parent = $child-\u003egetParent(); // $root\n$has = $root-\u003ehas($child); // true\n$root-\u003eremove($child);\n```\n\n### Create a tree from an array\n\n``` php\n\u003c?php\n\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\ItemFactory;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\BindFilter;\n\n...\n\n$array = [\n    'label'    =\u003e 'root',\n    'children' =\u003e [\n        ['label' =\u003e 'Item 1.1'],\n        ['label' =\u003e 'Item 1.2', 'children' =\u003e [['label' =\u003e 'Item 1.2.1']]],\n        ['label' =\u003e 'Item 1.3'],\n    ],\n];\n\n$factory = new ItemFactory(new BindFilter());\n$root = $factory-\u003ecreate($array);\n```\n\n### Match the current item\n\n``` php\n// Acme/DemoBundle/Navigation/NavigationBuilder.php\n\u003c?php\n\nnamespace Acme\\DemoBundle\\Navigation;\n\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\ItemFactory;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\BindFilter;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\FilterChain;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\MatchFilter;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\Matcher\\RoutesMatcher;\n\nclass NavigationBuilder\n{\n    ...\n\n    public function createNavigation()\n    {\n        $request = $this-\u003erequestStack-\u003egetMasterRequest();\n        $route = $request-\u003eattributes-\u003eget('_route');\n        $routeParams = $this-\u003erequest-\u003eattributes-\u003eget('_route_params', []);\n\n        $filter = new FilterChain([\n            $matchFilter = new MatchFilter(new RoutesMatcher($route, $routeParams)),\n            new BindFilter(),\n        ]);\n\n        $factory = new ItemFactory($filter);\n        $root = $factory-\u003ecreate([\n            'label'     =\u003e 'acme_demo.home',\n            'route'     =\u003e 'acme_demo_home',\n            'children'  =\u003e [\n                [\n                    'label'  =\u003e 'acme_demo.user_new',\n                    'route'  =\u003e 'acme_demo_user_new',\n                    'routes' =\u003e ['acme_demo_user_create'],\n                ],\n            ],\n        ]);\n\n        if (!$current = $matchFilter-\u003egetMatched()) {\n            $current = $root;\n        }\n        $current-\u003esetActive();\n\n        return ['root' =\u003e $root, 'current' =\u003e $current];\n    }\n}\n```\n\n### Default item properties\n\n``` php\n\u003c?php\n\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Item;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\ItemFactory;\nuse Rybakit\\Bundle\\NavigationBundle\\Navigation\\Filter\\BindFilter;\n\n...\n\n$item = new Item();\n\n// set translation domain to \"AcmeDemoBundle\" by default for all tree items\n$item-\u003etransDomain = 'AcmeDemoBundle';\n\n$factory = new ItemFactory(new BindFilter(), $item);\n$root = $factory-\u003ecreate($array);\n```\n\n### Twig\n\n```jinja\n{# simple render #}\n{{ nav(nav.root, \"my_block_name\", { \"opt1\": \"val1\", \"opt2\": \"val2\" }) }}\n\n{# render using tree filter #}\n{{ nav(nav.root|tree, \"nav\") }}\n\n{# render using tree filter with max depth = 1 #}\n{{ nav(nav.root|tree(1), \"nav\") }}\n\n{# render only visible items, max depth = 1 #}\n{{ nav(nav.root|tree(1)|visible, \"nav\") }}\n\n{# render only hidden items #}\n{{ nav(nav.root|tree|visible(false), \"nav\") }}\n\n{# render breadcrumbs #}\n{{ nav(nav.current|breadcrumbs, \"breadcrumbs\") }}\n\n{# render breadcrumbs with custom title at the end #}\n{{ nav(nav.current|breadcrumbs, \"breadcrumbs\", { \"last\": \"Custom title\" }) }}\n\n{# get root #}\n{{ nav.current|ancestor(0) }}\n\n{# get second level ancestor #}\n{{ nav.current|ancestor(2) }}\n\n{# get parent #}\n{{ nav.current|ancestor(-1) }}\n\n{# render submenu #}\n{{ nav(nav.current|ancestor(2)|tree(2)|visible, \"navlist\") }}\n```\n\n\n### Customising the navigation template\n\n```yaml\n# app/config/config.yml\nrybakit_navigation:\n    template: navigation.html.twig\n```\n\n```yaml\n# app/Resources/views/navigation.html.twig\n{% extends 'RybakitNavigationBundle::navigation.html.twig' %}\n\n# override the \"nav\" block\n{% block nav %}\n    \u003cul class=\"nav navbar-nav\"\u003e{{ block('nav_items') }}\u003c/ul\u003e\n{% endblock %}\n```\n\n\n## License\n\nRybakitNavigationBundle is released under the MIT License. See the bundled [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybakit%2Frybakitnavigationbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frybakit%2Frybakitnavigationbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybakit%2Frybakitnavigationbundle/lists"}