{"id":18907556,"url":"https://github.com/cesurapp/pd-widget","last_synced_at":"2025-04-15T04:32:04.069Z","repository":{"id":54447444,"uuid":"119257272","full_name":"cesurapp/pd-widget","owner":"cesurapp","description":"Symfony 5 Simple Widget Bundle","archived":false,"fork":false,"pushed_at":"2024-05-14T12:22:09.000Z","size":53,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T16:43:37.754Z","etag":null,"topics":["bundle","dashboard","pdadmin","symfony","symfony4","widget-library"],"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/cesurapp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fabpot","tidelift":"packagist/symfony/symfony","custom":"https://symfony.com/sponsor"}},"created_at":"2018-01-28T12:43:11.000Z","updated_at":"2024-01-10T20:30:22.000Z","dependencies_parsed_at":"2024-11-08T09:25:52.888Z","dependency_job_id":"d78f368b-e51b-442d-88ef-09bf77d06cab","html_url":"https://github.com/cesurapp/pd-widget","commit_stats":null,"previous_names":["cesurapp/pd-widget"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesurapp%2Fpd-widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesurapp%2Fpd-widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesurapp%2Fpd-widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesurapp%2Fpd-widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesurapp","download_url":"https://codeload.github.com/cesurapp/pd-widget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750075,"owners_count":21155685,"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","dashboard","pdadmin","symfony","symfony4","widget-library"],"created_at":"2024-11-08T09:22:08.902Z","updated_at":"2025-04-15T04:32:04.063Z","avatar_url":"https://github.com/cesurapp.png","language":"PHP","funding_links":["https://github.com/sponsors/fabpot","https://tidelift.com/funding/github/packagist/symfony/symfony","https://symfony.com/sponsor"],"categories":[],"sub_categories":[],"readme":"# pdWidget Bundle\nFlexible widget system for Symfony 5. \n\n[![Packagist](https://img.shields.io/packagist/dt/appaydin/pd-widget.svg)](https://github.com/appaydin/pd-widget)\n[![Github Release](https://img.shields.io/github/release/appaydin/pd-widget.svg)](https://github.com/appaydin/pd-widget)\n[![license](https://img.shields.io/github/license/appaydin/pd-widget.svg)](https://github.com/appaydin/pd-widget)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/appaydin/pd-widget.svg)](https://github.com/appaydin/pd-widget)\n\nInstallation\n---\n\n### Step 1: Download the Bundle\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```console\n$ composer require appaydin/pd-widget\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\n### Step 2: Enable the Bundle\n\nWith Symfony 4, the package will be activated automatically. But if something goes wrong, you can install it manually.\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `config/bundles.php` file of your project:\n\n```php\n\u003c?php\n// config/bundles.php\n\nreturn [\n    //...\n    Pd\\WidgetBundle\\PdWidgetBundle::class =\u003e ['all' =\u003e true]\n];\n```\n\nAdd Widget Routing:\n\n```yaml\n#config/routes.yaml\n\n# Widget Routing\nwidget:\n    resource: \"@PdWidgetBundle/Resources/config/routing.yml\"\n```\n\nEdit Doctrine Settings (`config/packages/doctrine.yaml`):\n\n```yaml\ndoctrine:\n    orm:\n        resolve_target_entities:\n            Pd\\WidgetBundle\\Entity\\UserInterface: App\\Entity\\User\n```\n\nUserInterface field, enter the class for the existing authorization system.\n\n### Step 3: Settings Bundle (Optional)\nYou can specify the template for the widget container.\n```yaml\n# config/packages/framework.yaml\n\npd_widget:\n    base_template: '@PdWidget/widgetBase.html.twig'\n    return_route: 'admin_dashboard'\n```\n\nCreate Your First Widget\n---\n\n#### Step 1: Create Widget Event Listener\n\nWidgets work with Event. Create Widget with Event Listener\n\n```php\n\u003c?php\n// src/Widgets/DashboardWidget.php\n\nnamespace App\\Widgets;\n\nuse Pd\\WidgetBundle\\Builder\\Item;\nuse Pd\\WidgetBundle\\Event\\WidgetEvent;\n\nclass Dashboard\n{\n    public function builder(WidgetEvent $event)\n    {\n        // Get Widget Container\n        $widgets = $event-\u003egetWidgetContainer();\n\n        // Add Widgets\n        $widgets\n            -\u003eaddWidget((new Item('user_info', 3600)) // Add Cache Time or Default 3600 Second\n                -\u003esetGroup('admin')\n                -\u003esetName('widget_user_info.name')\n                -\u003esetDescription('widget_user_info.description')\n                -\u003esetTemplate('widgets/userInfo.html.twig')\n                //-\u003esetContent('pdWidget Text Content')\n                //-\u003esetRole(['USER_INFO_WIDGET'])\n                -\u003esetData(function () {\n                    return ['userCount' =\u003e 5];\n                })\n                -\u003esetOrder(5)\n            );\n    }\n}\n```\n#### Step 2: Create Widget Template\nYou can create a Twig template for the widget or can only use text content.\n```twig\n# templates/userInfo.html.twig\n\n{% if widget.isActive %}\n    \u003cdiv class=\"col-lg-3 col-md-4 col-sm-6 col-6\"\u003e\n        \u003cdiv class=\"card text-center bg-primary text-white widget_user_info\"\u003e\n            \u003cdiv class=\"card-body\"\u003e\n                {# Action Button #}\n                {% include '@PdWidget/widgetAction.html.twig' %}\n\n                \u003cspan class=\"count\"\u003e{{ widget.data.userCount }}\u003c/span\u003e\n                \u003ch5 class=\"font-weight-light\"\u003e{{ 'widget_user_info.count'|trans }}\u003c/h5\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n{% endif %}\n```\n\n#### Step 3: Create Widget Services:\n```yaml\n# config/services.yaml\n\n# Load All Widgets\nApp\\Widgets\\:\n    resource: '../src/Widgets/*'\n    tags:\n        - { name: kernel.event_listener, event: widget.start, method: builder }\n        \n# Load Single Widget\nApp\\Widgets\\DashboardWidget:\n    tags:\n        - { name: kernel.event_listener, event: widget.start, method: builder }\n```\n\nRendering Widgets\n---\nThe creation process is very simple. You should use widget groups for widget creation.\n\n```twig\n# Render all 'admin' widget groups\n{{ pd_widget_render('admin') }}\n\n# Render selected widgets in 'admin' group\n{{ pd_widget_render('admin', ['user_info']) }}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesurapp%2Fpd-widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesurapp%2Fpd-widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesurapp%2Fpd-widget/lists"}