2017 © Pedro Peláez
 

symfony-bundle pd-widget

Symfony Simple Widget Bundle

image

rmznpydn/pd-widget

Symfony Simple Widget Bundle

  • Sunday, July 8, 2018
  • by rmznpydn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 467 % Grown

The README.md

pdWidget Bundle

Flexible widget system for Symfony 5., (*1)

Packagist Github Release license PHP from Packagist, (*2)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)

$ composer require appaydin/pd-widget

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*4)

Step 2: Enable the Bundle

With Symfony 4, the package will be activated automatically. But if something goes wrong, you can install it manually., (*5)

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:, (*6)

<?php
// config/bundles.php

return [
    //...
    Pd\WidgetBundle\PdWidgetBundle::class => ['all' => true]
];

Add Widget Routing:, (*7)

#config/routes.yaml

# Widget Routing
widget:
    resource: "@PdWidgetBundle/Resources/config/routing.yml"

Edit Doctrine Settings (config/packages/doctrine.yaml):, (*8)

doctrine:
    orm:
        resolve_target_entities:
            Pd\WidgetBundle\Entity\UserInterface: App\Entity\User

UserInterface field, enter the class for the existing authorization system., (*9)

Step 3: Settings Bundle (Optional)

You can specify the template for the widget container., (*10)

# config/packages/framework.yaml

pd_widget:
    base_template: '@PdWidget/widgetBase.html.twig'
    return_route: 'admin_dashboard'

Create Your First Widget

Step 1: Create Widget Event Listener

Widgets work with Event. Create Widget with Event Listener, (*11)

<?php
// src/Widgets/DashboardWidget.php

namespace App\Widgets;

use Pd\WidgetBundle\Builder\Item;
use Pd\WidgetBundle\Event\WidgetEvent;

class Dashboard
{
    public function builder(WidgetEvent $event)
    {
        // Get Widget Container
        $widgets = $event->getWidgetContainer();

        // Add Widgets
        $widgets
            ->addWidget((new Item('user_info', 3600)) // Add Cache Time or Default 3600 Second
                ->setGroup('admin')
                ->setName('widget_user_info.name')
                ->setDescription('widget_user_info.description')
                ->setTemplate('widgets/userInfo.html.twig')
                //->setContent('pdWidget Text Content')
                //->setRole(['USER_INFO_WIDGET'])
                ->setData(function () {
                    return ['userCount' => 5];
                })
                ->setOrder(5)
            );
    }
}

Step 2: Create Widget Template

You can create a Twig template for the widget or can only use text content., (*12)

# templates/userInfo.html.twig

{% if widget.isActive %}


{% endif %}

Step 3: Create Widget Services:

# config/services.yaml

# Load All Widgets
App\Widgets\:
    resource: '../src/Widgets/*'
    tags:
        - { name: kernel.event_listener, event: widget.start, method: builder }

# Load Single Widget
App\Widgets\DashboardWidget:
    tags:
        - { name: kernel.event_listener, event: widget.start, method: builder }

Rendering Widgets

The creation process is very simple. You should use widget groups for widget creation., (*13)

# Render all 'admin' widget groups
{{ pd_widget_render('admin') }}

# Render selected widgets in 'admin' group
{{ pd_widget_render('admin', ['user_info']) }}

The Versions

08/07 2018

dev-master

9999999-dev https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget

08/07 2018

1.0.04

1.0.04.0 https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget

08/07 2018

1.0.03

1.0.03.0 https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget

11/02 2018

1.0.02

1.0.02.0 https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget

11/02 2018

1.0.01

1.0.01.0 https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget

11/02 2018

1.0.0

1.0.0.0 https://github.com/rmznpydn/pd-widget

Symfony Simple Widget Bundle

  Sources   Download

MIT

The Requires

 

widget pdadmin pdwidget symfony-widget admin-widget