Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carono/yii2-behaviors
https://github.com/carono/yii2-behaviors
behavior url yii2
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/carono/yii2-behaviors
- Owner: carono
- License: mit
- Created: 2017-07-11T08:01:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-29T06:06:48.000Z (about 5 years ago)
- Last Synced: 2024-07-07T18:45:15.824Z (4 months ago)
- Topics: behavior, url, yii2
- Language: PHP
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
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]