Skip to content

Instantly share code, notes, and snippets.

@schmunk42
Created February 9, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmunk42/d3f3c2a5fb3d4d55b06e to your computer and use it in GitHub Desktop.
Save schmunk42/d3f3c2a5fb3d4d55b06e to your computer and use it in GitHub Desktop.
Yii2 module default view, showing all controllers in module (requires dmstr/yii2-application metadata)
<?php
use yii\helpers\Inflector;
?>
<div class="crud-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<div class="box">
<div class="box-header">
<h3 class="box-title">Module Controllers</h3>
</div>
<div class="box-body">
<?php
foreach (\Yii::$app->getModule('admin')->getControllers($this->context->module->id) AS $i => $controller) {
echo yii\helpers\Html::a(
Inflector::camel2words(Inflector::id2camel($controller)),
["/{$this->context->module->id}/$controller"],
['class' => 'col-sm-3 btn btn-lg btn-default btn-flat']
);
}
?>
<div class="clearfix"></div>
</div>
<!-- /.box-body -->
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment