{"id":18903577,"url":"https://github.com/intaro/twig-injection-bundle","last_synced_at":"2025-08-21T09:33:00.578Z","repository":{"id":19364769,"uuid":"22604786","full_name":"intaro/twig-injection-bundle","owner":"intaro","description":"Allow to inject the twig templates through the event behavior","archived":false,"fork":false,"pushed_at":"2024-10-11T10:38:51.000Z","size":18,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-26T00:04:44.748Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/intaro.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":"2014-08-04T13:20:18.000Z","updated_at":"2024-10-11T10:37:43.000Z","dependencies_parsed_at":"2022-08-21T12:50:42.114Z","dependency_job_id":null,"html_url":"https://github.com/intaro/twig-injection-bundle","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/intaro/twig-injection-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Ftwig-injection-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Ftwig-injection-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Ftwig-injection-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Ftwig-injection-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intaro","download_url":"https://codeload.github.com/intaro/twig-injection-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Ftwig-injection-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271455681,"owners_count":24762773,"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-08-21T02:00:08.990Z","response_time":74,"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":[],"created_at":"2024-11-08T09:05:41.180Z","updated_at":"2025-08-21T09:33:00.309Z","avatar_url":"https://github.com/intaro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TwigInjectionBundle\n\nThe TwigInjectionBundle allows to inject twig templates through the event behavior.\n\n## Installation\n\nTwigInjectionBundle requires Symfony 3.4 or higher.\n\nRequire the bundle in your `composer.json` file:\n\n```json\n{\n    \"require\": {\n        \"intaro/twig-injection-bundle\": \"^2.0\"\n    }\n}\n```\n\nRegister the bundle in `AppKernel`:\n\n```php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = [\n        //...\n\n        new Intaro\\TwigInjectionBundle\\IntaroTwigInjectionBundle(),\n    ];\n\n    //...\n}\n```\n\nInstall the bundle:\n\n```\n$ composer update intaro/twig-injection-bundle\n```\n\n## Usage\n\n1) Add `{{ inject() }}` calling in template:\n\n```twig\n{{ inject('twig.injection.event.name', { parameter1: 'some-value', parameter2: some_object }) }}\n```\n\n2) Prepare controller action which you want to render or template which you want to include.\n\n3) Define Listener which will inject `include` or `render` calling:\n\n```php\n\u003c?php\n\nnamespace Acme\\DemoBundle\\EventListener;\n\nuse Intaro\\TwigInjectionBundle\\Event\\TwigInjectEvent;\nuse Intaro\\TwigInjectionBundle\\Event\\TwigInjectRender;\n\nclass TwigInjectionListener\n{\n    public function onSomeEvent(TwigInjectEvent $event)\n    {\n        $parameters = $event-\u003egetParameters();\n\n        if (!isset($parameters['parameter1']) || 'some-value' !== $parameters['parameters1']) {\n            return;\n        }\n\n        $render = new TwigInjectRender(\n            'AcmeDemoBundle:DefaultController:index',\n            [ 'object' =\u003e $parameters['parameters2'] ]\n        );\n        $event-\u003eaddInjection($render);\n\n        $include = new TwigInjectInclude('AcmeDemoBundle:Default:someTemplate.html.twig');\n        $event-\u003eaddInjection($include);\n    }\n}\n```\n\n4) Register the listener:\n\n```yaml\nservices:\n    acme_demo.twig_injection.listener:\n        class: Acme\\DemoBundle\\EventListener\\TwigInjectionListener\n        tags:\n            - { name: kernel.event_listener, event: twig.injection.event.name, method: onSomeEvent }\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Ftwig-injection-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintaro%2Ftwig-injection-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Ftwig-injection-bundle/lists"}