Skip to content

Commit

Permalink
use statements for CP route example
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Feb 1, 2017
1 parent 7d0c2a6 commit 8a6ee8c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions en/cp-section.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ At a minimum, that template should extend Craft’s `_layouts/cp` layout templat
Alternatively, you can route requests to `/admin/plugin-handle` to a controller action (or a different template) by registering a Control Panel route from your plugin’s `init()` method:

```php
use craft\events\RegisterUrlRulesEvent;
use craft\web\UrlManager;
use yii\base\Event;


public function init()
{
yii\base\Event::on(
craft\web\UrlManager::class,
craft\web\UrlManager::EVENT_REGISTER_CP_URL_RULES,
function(craft\events\RegisterUrlRulesEvent $event) {
$event->rules['plugin-handle'] = 'plugin-handle/foo/bar';
}
);
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function(RegisterUrlRulesEvent $event) {
$event->rules['plugin-handle'] = 'plugin-handle/foo/bar';
});
}
```

0 comments on commit 8a6ee8c

Please sign in to comment.