{"id":24650758,"url":"https://github.com/tangoman75/callbackbundle","last_synced_at":"2025-09-02T13:45:19.655Z","repository":{"id":57064970,"uuid":"100727953","full_name":"TangoMan75/CallbackBundle","owner":"TangoMan75","description":"TangoMan Callback Twig Extension Bundle provides simple callbacks manager for twig, avoids unnecessary callbacks to stack up indefinitely","archived":false,"fork":false,"pushed_at":"2025-07-11T13:53:07.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-19T23:14:07.165Z","etag":null,"topics":["avoids-unnecessary-callbacks","bundle","callback","callback-manager","extension","service","symfony","tangoman-callbackbundle","twig"],"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/TangoMan75.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":null,"security":null,"support":null}},"created_at":"2017-08-18T15:53:06.000Z","updated_at":"2025-07-11T13:53:10.000Z","dependencies_parsed_at":"2022-08-24T14:01:28.580Z","dependency_job_id":null,"html_url":"https://github.com/TangoMan75/CallbackBundle","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/TangoMan75/CallbackBundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoMan75%2FCallbackBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoMan75%2FCallbackBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoMan75%2FCallbackBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoMan75%2FCallbackBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TangoMan75","download_url":"https://codeload.github.com/TangoMan75/CallbackBundle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangoMan75%2FCallbackBundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273293947,"owners_count":25079892,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["avoids-unnecessary-callbacks","bundle","callback","callback-manager","extension","service","symfony","tangoman-callbackbundle","twig"],"created_at":"2025-01-25T18:16:36.401Z","updated_at":"2025-09-02T13:45:19.647Z","avatar_url":"https://github.com/TangoMan75.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GH language](https://img.shields.io/github/languages/top/TangoMan75/CallbackBundle)\n[![GH release](https://img.shields.io/github/v/release/TangoMan75/CallbackBundle)](https://github.com/TangoMan75/CallbackBundle/releases)\n![GH license](https://img.shields.io/github/license/TangoMan75/CallbackBundle)\n![GH stars](https://img.shields.io/github/stars/TangoMan75/CallbackBundle)\n[![PHP CI](https://github.com/TangoMan75/CallbackBundle/workflows/PHP%20CI/badge.svg)](https://github.com/TangoMan75/CallbackBundle/actions/workflows/php.yml)\n![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2FTangoMan75%2FCallbackBundle\u0026labelColor=%23697689\u0026countColor=%2337d67a\u0026style=flat)\n\nTangoMan Callback Twig Extension Bundle\n=======================================\n\n**TangoMan Callback Twig Extension Bundle** provides simple callback function for twig which avoids unnecessary callbacks to stack up indefinitely in users query string.\n\n🧩 Purpose of the `Callback` Class\n----------------------------------\n\nThis class defines a Twig extension that introduces a custom function called `callback`. Its main job is to **generate clean URLs** by **removing `callback` parameters from query strings**, which can help avoid issues where multiple callbacks get appended indefinitely and make sure users query parameters are not lost in the process.\n\n🔧 `callbackFunction()`\n-----------------------\n\n```php\npublic function callbackFunction($route = null, $parameters = [])\n```\n\n- **Behavior**:\n  - If no route is provided -\u003e use the current request URI.\n  - If a route is specified -\u003e generate a full URL using Symfony's router.\n- **Core logic**:\n  - Parses the URL.\n  - Removes the `callback` parameter from the query string.\n  - Reconstructs and returns the cleaned URL.\n\n✨ Real-Life Use Case\n---------------------\n\nImagine you're building a redirect system where callbacks are passed through URLs. If multiple redirects occur (e.g., login flow, third-party auth, or form submissions), you might get URLs like this:\n\n```\nhttps://example.com/page?callback=https://another.com?callback=...\n```\n\nThis class avoids that endless loop by **stripping the `callback`** query parameter from the final URL so it stays nice and tidy.\n\n📦 Installation\n===============\n\nStep 1: Download the Bundle\n---------------------------\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```bash\ncomposer require tangoman/callback-bundle\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\nStep 2: Enable the Bundle\n-------------------------\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `app/AppKernel.php` file of your project:\n\n```php\n\u003c?php\n// app/AppKernel.php\n\n// ...\nclass AppKernel extends Kernel\n{\n    // ...\n\n    public function registerBundles()\n    {\n        $bundles = array(\n            // ...\n            new TangoMan\\CallbackBundle\\TangoManCallbackBundle(),\n        );\n\n        // ...\n    }\n}\n```\n\nYou don't have to add **TangoMan Callback Twig Extension Bundle** to the `service.yml` of your project. \n**twig.extension.callback** service will load automatically.\n\n🛠️ Usage\n=======\n\n```\ncallback(route = null, parameters = [])\n```\nReturns current URI removing `callback` from query string.\nOptionally, returns the absolute URL (with scheme and host) for the given route with given parameters, `callback` will be ignored as well.\n\n|           | route  (optional) | parameters (optional)   |\n| :-------- | :------------     | :---------------------- |\n| type      | string            | array                   |\n| default   | current uri       | []                      |\n\nInside your views:\n\nBy default callback will be defined on user's current page. \n```twig\n    \u003ca href=\"{{ path('app_foo_bar', { 'callback': callback() }) }}\"\u003e\n        Your Foo Bar link here\n    \u003c/a\u003e\n```\n\nBut you can optionally redirect user to any route.\n```twig\n    \u003ca href=\"{{ path('app_delete_foo', { 'callback': callback('app_trash_bin', { 'slug': 'foo' } ) }) }}\"\u003e\n        Your Foo Bar link here\n    \u003c/a\u003e\n```\nCallback function accepts route name and parameters for desired route.\n\nInside your action method:\n```php\n    public function foobarAction(Request $request)\n    {\n        ...\n        // User is redirected to referrer page\n        return $this-\u003eredirect($request-\u003eget('callback'));\n        ...\n    }\n```\n\n✅ Tests\n========\n\n**TangoMan Callback Twig Extension Bundle** provides Makefile script to perform unit tests, in order to fit in your continuous integration workflow.\n\nEnter following command to install required dependencies and execute unit tests:\n\n```bash\n$ make tests\n```\n\nOn windows machine you will need to install [cygwin](http://www.cygwin.com/) or [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) first to execute make script.\n\nIf you have XDebug installed, you can generate code coverage report with:\n```bash\n$ make coverage\n```\n\n📝 Note\n=======\n\n[![Build Status](https://travis-ci.org/TangoMan75/CallbackBundle.svg?branch=master)](https://travis-ci.org/TangoMan75/CallbackBundle) \nIf you find any bug please report here : [Issues](https://github.com/TangoMan75/CallbackBundle/issues/new)\n\n🤝 Contributing\n---------------\n\nThank you for your interest in contributing to **TangoMan Callback Twig Extension Bundle**.\n\nPlease review the [code of conduct](./CODE_OF_CONDUCT.md) and [contribution guidelines](./CONTRIBUTING.md) before starting to work on any features.\n\nIf you want to open an issue, please check first if it was not [reported already](https://github.com/TangoMan75/CallBackBundle/issues) before creating a new one.\n\n📜 License\n----------\n\nCopyrights (c) 2025 \u0026quot;Matthias Morin\u0026quot; \u0026lt;mat@tangoman.io\u0026gt;\n\n[![License](https://img.shields.io/badge/Licence-MIT-green.svg)](LICENSE)\nDistributed under the MIT license.\n\nIf you like **TangoMan Callback Twig Extension Bundle** please star, follow or tweet:\n\n[![GitHub stars](https://img.shields.io/github/stars/TangoMan75/CallBackBundle?style=social)](https://github.com/TangoMan75/CallBackBundle/stargazers)\n[![GitHub followers](https://img.shields.io/github/followers/TangoMan75?style=social)](https://github.com/TangoMan75)\n[![Twitter](https://img.shields.io/twitter/url?style=social\u0026url=https%3A%2F%2Fgithub.com%2FTangoMan75%2FCallBackBundle)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2FTangoMan75%2FCallBackBundle)\n\n... And check my other cool projects.\n\n👋 Let's Build Your Next Project Together !\n-------------------------------------------\n\nLooking for an experienced Full-Stack Partner ?\n\nClean code. Clear communication.\n\nFrom first sketch to final launch, I've got your back.\n\n[![tangoman.io](https://img.shields.io/badge/✉️%20Get%20in%20touch%20now%20!-FD9400?style=for-the-badge)](https://tangoman.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangoman75%2Fcallbackbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangoman75%2Fcallbackbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangoman75%2Fcallbackbundle/lists"}