Yii Framework Forum: sRBAC Question: SBaseController extends from CController or Controller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

sRBAC Question: SBaseController extends from CController or Controller Rate Topic: -----

#1 User is offline   Boy.Lee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 03-September 10

Posted 09 November 2010 - 03:52 AM

Hi Spyros,

I am working on srbac recently, I set up everything, and asset roles, tasks and options, everything is looking fine, but when I extends my controller PostController from SBaseController, there is a Exception appearance.

Here is some log,
CException

Description

Property "PostController.breadcrumbs" is not defined.

Source File

/Users/Seelove00/Working/www/b2/protected/views/post/admin.php(2)

00001: <?php
00002: $this->breadcrumbs=array(
00003:     'Manage Posts',
00004: );
00005: 
00006: ?>
00007: 
00008: <h1>Manage Posts</h1>
00009: 
00010: 
00011: <?php $this->widget('zii.widgets.grid.CGridView', array(
00012:     'dataProvider'=>$model->search(),
00013:     'filter'=>$model,
00014:     'columns'=>array(
Stack Trace

#0 /Users/Seelove00/Working/www/b2/protected/views/post/admin.php(2): CComponent->__set('breadcrumbs', Array)
#1 /Users/Seelove00/Working/www/yii/framework/web/CBaseController.php(119): require('/Users/Seelove0...')
#2 /Users/Seelove00/Working/www/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/Seelove0...', Array, true)
#3 /Users/Seelove00/Working/www/yii/framework/web/CController.php(798): CBaseController->renderFile('/Users/Seelove0...', Array, true)
#4 /Users/Seelove00/Working/www/yii/framework/web/CController.php(739): CController->renderPartial('admin', Array, true)
#5 /Users/Seelove00/Working/www/b2/protected/controllers/PostController.php(163): CController->render('admin', Array)
#6 /Users/Seelove00/Working/www/yii/framework/web/actions/CInlineAction.php(50): PostController->actionAdmin()
#7 /Users/Seelove00/Working/www/yii/framework/web/CController.php(300): CInlineAction->run()
#8 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilterChain.php(133): CController->runAction(Object(CInlineAction))
#9 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilter.php(41): CFilterChain->run()
#10 /Users/Seelove00/Working/www/yii/framework/web/CController.php(1049): CFilter->filter(Object(CFilterChain))
#11 /Users/Seelove00/Working/www/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#12 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
#13 /Users/Seelove00/Working/www/yii/framework/web/CController.php(283): CFilterChain->run()
#14 /Users/Seelove00/Working/www/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#15 /Users/Seelove00/Working/www/yii/framework/web/CWebApplication.php(324): CController->run('admin')
#16 /Users/Seelove00/Working/www/yii/framework/web/CWebApplication.php(121): CWebApplication->runController('post/admin')
#17 /Users/Seelove00/Working/www/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#18 /Users/Seelove00/Working/www/b2/index.php(13): CApplication->run()
#19 {main}
2010-11-09 16:38:48 Apache/2.2.15 (Unix) PHP/5.3.3 mod_ssl/2.2.15 OpenSSL/0.9.8o Yii Framework/1.1.4


Looking at this CException, I think back and find that my original PostController is extends from Controller so I changed "class SBaseController extends CController" to "class SBaseController extends Controller"

Now, everything is fine now, but I have no idea what I have done, and what will happen.

I need a little concept about this change.

thank you, and everyone who can give me a tip.
Love Yii, Love BoyLee ^&^

Looking for Yii Project, if you have please PM me. :)

My Blog => YiiBlog.info
0

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 09 November 2010 - 04:14 AM

View PostBoy.Lee, on 09 November 2010 - 03:52 AM, said:

Hi Spyros,

I am working on srbac recently, I set up everything, and asset roles, tasks and options, everything is looking fine, but when I extends my controller PostController from SBaseController, there is a Exception appearance.

Here is some log,
CException

Description

Property "PostController.breadcrumbs" is not defined.

Source File

/Users/Seelove00/Working/www/b2/protected/views/post/admin.php(2)

00001: <?php
00002: $this->breadcrumbs=array(
00003: 	'Manage Posts',
00004: );
00005: 
00006: ?>
00007: 
00008: <h1>Manage Posts</h1>
00009: 
00010: 
00011: <?php $this->widget('zii.widgets.grid.CGridView', array(
00012: 	'dataProvider'=>$model->search(),
00013: 	'filter'=>$model,
00014: 	'columns'=>array(
Stack Trace

#0 /Users/Seelove00/Working/www/b2/protected/views/post/admin.php(2): CComponent->__set('breadcrumbs', Array)
#1 /Users/Seelove00/Working/www/yii/framework/web/CBaseController.php(119): require('/Users/Seelove0...')
#2 /Users/Seelove00/Working/www/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/Seelove0...', Array, true)
#3 /Users/Seelove00/Working/www/yii/framework/web/CController.php(798): CBaseController->renderFile('/Users/Seelove0...', Array, true)
#4 /Users/Seelove00/Working/www/yii/framework/web/CController.php(739): CController->renderPartial('admin', Array, true)
#5 /Users/Seelove00/Working/www/b2/protected/controllers/PostController.php(163): CController->render('admin', Array)
#6 /Users/Seelove00/Working/www/yii/framework/web/actions/CInlineAction.php(50): PostController->actionAdmin()
#7 /Users/Seelove00/Working/www/yii/framework/web/CController.php(300): CInlineAction->run()
#8 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilterChain.php(133): CController->runAction(Object(CInlineAction))
#9 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilter.php(41): CFilterChain->run()
#10 /Users/Seelove00/Working/www/yii/framework/web/CController.php(1049): CFilter->filter(Object(CFilterChain))
#11 /Users/Seelove00/Working/www/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain))
#12 /Users/Seelove00/Working/www/yii/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))
#13 /Users/Seelove00/Working/www/yii/framework/web/CController.php(283): CFilterChain->run()
#14 /Users/Seelove00/Working/www/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
#15 /Users/Seelove00/Working/www/yii/framework/web/CWebApplication.php(324): CController->run('admin')
#16 /Users/Seelove00/Working/www/yii/framework/web/CWebApplication.php(121): CWebApplication->runController('post/admin')
#17 /Users/Seelove00/Working/www/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()
#18 /Users/Seelove00/Working/www/b2/index.php(13): CApplication->run()
#19 {main}
2010-11-09 16:38:48 Apache/2.2.15 (Unix) PHP/5.3.3 mod_ssl/2.2.15 OpenSSL/0.9.8o Yii Framework/1.1.4


Looking at this CException, I think back and find that my original PostController is extends from Controller so I changed "class SBaseController extends CController" to "class SBaseController extends Controller"

Now, everything is fine now, but I have no idea what I have done, and what will happen.

I need a little concept about this change.

thank you, and everyone who can give me a tip.


Your should make Controller (found in components) extend SBaseController.
Then you don't have to change all your controllers (That already extend Controller )
0

#3 User is offline   Boy.Lee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 03-September 10

Posted 09 November 2010 - 05:48 AM

I found another way.

<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class Controller extends CController
{
	/**
	 * @var string the default layout for the controller view. Defaults to '//layouts/column1',
	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
	 */
	public $layout='//layouts/column1';
	/**
	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
	 */
	public $menu=array();
	/**
	 * @var array the breadcrumbs of the current page. The value of this property will
	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
	 * for more details on how to specify this property.
	 */
	public $breadcrumbs=array();
}


so there are three solutions.

one make Controller extends SBaseController, then SBaseController extends CController

two copy three public var to SBaseController and change all controller extends SBaseController, and SBaseController extends CControler

three change all controllers extends SBaseController, then SBaseController extends Controller

logically, all of three will working...

thx,Spyros
Love Yii, Love BoyLee ^&^

Looking for Yii Project, if you have please PM me. :)

My Blog => YiiBlog.info
0

#4 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 10 November 2010 - 03:11 AM

I think the first is the best because you won't have to make changes to SBaseController (and then lose them on a srbac update)
0

#5 User is offline   Boy.Lee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 03-September 10

Posted 11 November 2010 - 03:58 AM

the srbac is amazing, I love it, thx.
Love Yii, Love BoyLee ^&^

Looking for Yii Project, if you have please PM me. :)

My Blog => YiiBlog.info
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users