carono/yii2-behaviors

Installs: 573

Dependents: 1

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

0.3.4 2019-04-05 13:50 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]