Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/carono/yii2-behaviors


https://github.com/carono/yii2-behaviors

behavior url yii2

Last synced: about 5 hours ago
JSON representation

Awesome Lists containing this project

README

        

```php
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]