Closed mithun12000 closed 10 years ago
why do you need beforeAction to change the layout? What are you trying to achieve?
I am creating a theme. now default layout can be anything, but when you activate theme then it will overwrite layout to change UI.
You can class-level events: https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-events.md#class-level-event-handlers You can attach your event handler during bootstrap of the application: https://github.com/yiisoft/yii2/blob/master/framework/base/Application.php#L173
Hi qiangxue,
how can i make use of You can attach your event handler during bootstrap of the application: https://github.com/yiisoft/yii2/blob/master/framework/base/Application.php#L173
?
could you explain what can be done through this and how it can be specify?
I have config some thing like:
[
'id' => 'Test Application',
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'extensions' => require(dirname(dirname(dirname(dirname(__DIR__)))) . '/extensions/extensions.php'),
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=tc_backend',
'username' => 'root',
'password' => '',
'charset' => 'utf8'
],
'authManager' => [
'class' => 'yii\rbac\DbManager', // THIS IS YOUR AUTH MANAGER
'db' => 'db',
'assignmentTable' => 'user',
],
],
];
extensions
will hold component/extension configuration.
You need to create a class and list it in Application::bootstrap
. Within this class, you can register the class-level event handler for yii\web\Controller::EVENT_BEFORE_ACTION
event.
sorry my question is similar but yet it is a different here i am trying to make it work this bootstrap feature.
my extension config:
'adminUi' =>
array (
'name' => 'adminUi',
'version' => '1.0',
'bootstrap' => 'yii/adminUi/AdminUiBootstrap',
'alias' =>
array (
'@yii/adminUi' => $vendorDir . '/adminUi',
'@vendor/adminUi/assets/' => $vendorDir . '/adminUi/assets',
'@app/themes/adminui' => $vendorDir . '/adminUi/themes/',
),
),
path
[root]
|_extension
|_app
| |application
| |_backend
|_framework
$vendorDir = [root]/extension
Now when i am trying to make this work i always get reflection error
ReflectionException
Class yii/adminUi/AdminUiBootstrap does not exist
but file already exist in [root]/extension/adminUi/AdminUiBootstrap
also this is implemented BootstrapInterface
.
may i know where is the error?
also
bootstrap file def:
namespace yii\adminUi;
use Yii;
use yii\base\Application;
use yii\base\BootstrapInterface;
class AdminUiBootstrap implements BootstrapInterface{
public function bootstrap($app){
print_r($app);
}
}
You didn't specify the class name correctly. Please read the guide first: https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-autoloading.md https://github.com/yiisoft/yii2/blob/master/docs/guide/structure-applications.md#yiibaseapplicationbootstrapbootstrap-
Thanks. find my error.
yii/adminUi/AdminUiBootstrap
should be yii\adminUi\AdminUiBootstrap
I am trying to achieve this to create a theme. but i don't know how i can achieve. I have gone through you doc too.