PHPackages                             unyii2/yii2-panel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. unyii2/yii2-panel

ActiveLibrary[Admin Panels](/categories/admin)

unyii2/yii2-panel
=================

yii2 panel module

1.0.2(4y ago)3633↓50%2BSD-4-ClausePHPPHP 7.\*

Since Feb 8Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/unyii2/yii2-panel)[ Packagist](https://packagist.org/packages/unyii2/yii2-panel)[ Docs](https://github.com/unyii2/yii2-panel.git)[ RSS](/packages/unyii2-yii2-panel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

yii2 panel controller
=====================

[](#yii2-panel-controller)

[![Total Downloads](https://camo.githubusercontent.com/7435e5e8b7966ac687a974ef385380756798c7c276a04a07752ecc16d6dce41e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f756e796969322f796969322d70616e656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unyii2/yii2-panel)

Yii2Panel was designed to make boards that display different panels from different modules/extensions with access rights control.

Meeting better as expected, as the Yii2Panel can be used for displaying panel from any other module/extension with access control.

Another benefit is that the panels to be displayed are assigned to a module configuration that allows different panels to be used in the module for different projects.

For procesing submited data from PanelWidgwet van use PanleLogic

Realisation
-----------

[](#realisation)

Simply dashboard solution. Each dashboard panel define as panel controller action identically as Yii page:

- panel controller in behaviors can control access - panel display only for users, who has access;
- panel controller controller action for creating HTML or response;
- create view folder in same folder, where all module controller views;
- for displaying add PanelWidget like anchor in view file;
- in module config for PanelWidget set one or more panels as Yii routes with parameters to panel controller;

Sequence
--------

[](#sequence)

- PanelWidget get panel list from module configuration
- PanelWidget call panel controller action with parameters
- Panel controller validate access. If no access, return empty string
- panel controller action create response HTML
- PanelWidget output response HTML

Installation by composer
------------------------

[](#installation-by-composer)

```
{
    "require": {
       "unyii2/yii2-panel": "dev-master"
    }
}

Or

$ composer require unyii2/yii2-panel "dev-master"

```

Widget
======

[](#widget)

```
echo \unyii2\yii2panel\PanelWidget::widget([
    'name' => 'exportSettings',
    'params' => [
        'docId' => 777
    ]
]);
```

Controller action
=================

[](#controller-action)

For processing submited data form panel widget can use PanelLogic

```
    public function actionCreate()
    {

        $model = new RkInvoiceForm();
        if($model->load($request->post()) && $model->save()) {
            $panelLogic = Yii::createObject([
                'class' => PanelLogic::class,
                'name' => 'LietvedibaRkInvoiceSave',
                'params' => [
                    'modelRecordId' => $model->id
                ]
            ]);
            $panelLogic->run();
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', [
            'model' => $model,
        ]);

    }
```

Module config
=============

[](#module-config)

To module add parameter 'panels' and in configuration for module add panels routes

```
        'invoices' => [
            'class' => 'd3modules\d3invoices\Module',
            'panels' => [
                /** for widget */
                'exportSettings' => [
                    [
                        'route' => 'd3accexport/invoice-panel/document-settings',
                        'params' => [
                            'docId' => 13 // action parameter value
                         ]
                        'tag' => 'div', // optinal. Add enclosing tag to panel
                        'options' => ['class' => 'col-sm-8 col-md-6 col-lg-4'] //enclosing tag options
                     ]
                 ],
                 /** for panel logic */
                 'LietvedibaRkInvoiceSave' => [
                    [
                        'route' => 'deal/panel/save'
                    ]
                ],
            ],
        ],
```

To controller add parameter 'panels' and in configuration for module add panels routes

```
        'invoices' => [
            'class' => 'd3modules\d3invoices\Module',
            'controllerMap' => [
                'settings' => [
                    'class' => 'yii3\persons\controllers\SettingsController',
                    'panels' => [
                        'UserSettingsProvileLeft' =>
                            [
                                [
                                    'route' => 'myauth/panel/show-qrc'
                                 ]
                            ]
                    ]
                ],
            ],
```

Optionally, if no possible add to module parameter 'panels', panel routes can define in parameters

```
'params' => [
    'panelWidget' => [
        'dashboard' => [
            'last' =>  [
                [
                    'route' => 'delivery/panel/transit-declarations',
                    /**
                     * parameters for action method:
                     * public function actionMyTransitDeclarations(array $statusIdList): string
                     */
                    'params' => [
                        'statusIdList' => [5, 20]
                    ]
                ]
            ],
        ]
    ],
]
```

Panel controller with access control and view rendering
=======================================================

[](#panel-controller-with-access-control-and-view-rendering)

Standard view path: d3modules/d3accexport/views/invoice-panel/setting\_grid.php

```
