Nested Extension inside Moduel

Hi Everyone,

Stats:

-Ubuntu 10.4

-Yii 1.1.4.r2429

-PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:41:55) Copyright © 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies

I am creating a module with a nested extension and am wondering the appropriate way to access the nested extension throughout my application. Here is my config/main.php that will hopefully explain what I am trying to accomplish.




<?php

...

	'modules'=>array(

            'abm'=>array(

                'import'=>array(

                    'application.modules.abm.models.*',

                    'application.modules.abm.components.*',


                ),

                'components'=>array(

                    'abt'=> array(

                        'class'=>'application.modules.abm.extensions.abt.AbtController',

                    ),

                    'db'=>array(

                        'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/abt.db',

                    ),

                ),

            ),

            /*

            'gii'=>array(

                    'class'=>'system.gii.GiiModule',

                    'password'=>'Enter Your Password Here',

            ),

            */

	),

...

?>



Normally I would just place my extension in the protected/extension folder and make the call to Yii::app()->abt or like the documentation describes, Yii::app()->xyz.

I can use CVarDumper::dump() on Yii::app()->modules array and see that indeed Yii is loading everything correctly.




array ( 'abm' => array ( 'import' => array ( '0' => 'application.modules.abm.models.*' '1' => 'application.modules.abm.components.*' ) 'components' => array ( 'abt' => array ( 'class' => 'application.modules.abm.extensions.abt.AbtController' ) 'db' => array ( 'connectionString' => 'sqlite:/REDACTED/protected/config/../data/abt.db' ) ) 'class' => 'abm.AbmModule' ) ) 



But I still don’t know how to access the nested extension. I feel like it should be Yii::app()->abm->abt but that isn’t correct.

I could use some advice on how to proceed.

-thanks

jared

Try


Yii::app()->getModule('abm')->db

Thank you very much, that did the trick! Just to clarify for someone else coming along.

I was able to access the database extension as well as my own personal extension by using this code.





$db = Yii::app()->getModule('abm')->db;

$adt = Yii::app()->getModule('abm')->abt;