carono/yii2-behaviors

Installs: 1 864

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

0.3.4 2019-04-05 13:50 UTC

This package is auto-updated.

Last update: 2024-11-29 05:32:33 UTC


README

 public function behaviors()
    {
        return [
            'urls' => [
                'class' => UrlBehavior::class,
                'rules' => [
                    [
                        'view-content',
                        'url' => function ($model, $params) {
                            return $model->is_main ? ['/'] : ['/menu/view'] + $params;
                        },
                        'params' => ['id']
                    ],
                    ['view', 'url' => ['/admin/menu/view'], 'params' => ['id'], 'role' => ['root']],
                ]
            ]
        ];
    }

function getUrl($action, $asString = false)

$url = $model->getUrl('view'); // array ['/admin/menu/view','id'=>1]