PHP code example of appaydin / pd-widget

1. Go to this page and download the library: Download appaydin/pd-widget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

appaydin / pd-widget example snippets



// config/bundles.php

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


// 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)
            );
    }
}