Yuri_33
(Yuri!)
May 12, 2011, 2:40pm
1
I use extension in my module.
When i write in the module init() function:
$this->setComponents(array(
'some_extension' => array(...),
));
But when i put this code in the main.php config:
'components'=>array(
...
'some_extension' => array(...),
...
How i can register extension component into my module ? (and make preload too)
Thank you
Yuri_33
(Yuri!)
May 23, 2011, 3:48pm
2
Anybody knows ?
For example i use extension only in the backend/admin part, so don’t need to load this on the application start…
Asgaroth
(Asgaroth Belem)
May 23, 2011, 3:58pm
3
In your main I think it should be something like:
'modules' => array(
'yourmodule' => array(
'components' => array(
'yourextension => array()...
),
),
)
hermesck
(Radim)
June 28, 2011, 2:33pm
4
Try Yii::app()->setComponents().
I’am using it for components setting of my module like this:
// Load AdminModule config
$moduleConfig = require('config'.DIRECTORY_SEPARATOR.'main.php');
// Override/Merge/Create application components settings
Yii::app()->setComponents($moduleConfig['components']);
dcmouser
(Info)
August 7, 2011, 11:24pm
5
Thanks very much HermesCK and others – I was having the same problam and the suggestion to call Yii::app()->setComponents from the module init, instead of $this->setComponents solved it.
nevernet
(Ysixin)
October 24, 2013, 10:39am
6
it’s not 100% correct.
i suggest to define components in main.php
'modules'=>array(
'www'=>array(
'class'=>'applications.modules.www.WwwModule',
'components' => array(
'api'=>array('class'=>'www.components.ApiBase'),
'curl'=>array('class'=>'www.vendors.Curl'),
),
),
),
and then:
$api = $this->getModule()->api;
$curl = $this->getModule()->curl;
"$this" is current controller.
one more thing:
‘api’=>array(‘class’=>‘www.components.ApiBase’),
"www" is path alias here, and it will be created automatically when you setup module