crud генератор выполняется в обход конфига, и так:
когда захожу что бы сгенерировать модель выдаёт ошибку:
Код: Выделить всё
Property "CWebUser.role" is not defined.
Код: Выделить всё
X:\home\test1.ru\framework\web\auth\CWebUser.php(141)
129
130 /**
131 * PHP magic method.
132 * This method is overriden so that persistent states can be accessed like properties.
133 * @param string $name property name
134 * @return mixed property value
135 */
136 public function __get($name)
137 {
138 if($this->hasState($name))
139 return $this->getState($name);
140 else
141 return parent::__get($name);
142 }
143
144 /**
145 * PHP magic method.
146 * This method is overriden so that persistent states can be set like properties.
147 * @param string $name property name
148 * @param mixed $value property value
149 */
150 public function __set($name,$value)
151 {
152 if($this->hasState($name))
153 $this->setState($name,$value);
Stack Trace #0 + X:\home\test1.ru\framework\web\auth\CWebUser.php(141): CComponent->__get("role")
#1 – X:\home\test1.ru\subdomain\protected\components\PhpAuthManager.php(16): CWebUser->__get("role")
#2 + X:\home\test1.ru\framework\base\CModule.php(388): PhpAuthManager->init()
#3 + X:\home\test1.ru\framework\gii\generators\model\ModelCode.php(428): CModule->getComponent("authManager")
#4 + X:\home\test1.ru\framework\gii\generators\model\ModelCode.php(407): ModelCode->isDbConnection("authManager", array("class" => "PhpAuthManager", "defaultRoles" => array("guest")))
#5 + X:\home\test1.ru\framework\gii\generators\model\views\index.php(43): ModelCode->getConnectionList()
#6 + X:\home\test1.ru\framework\web\CBaseController.php(127): require("X:\home\test1.ru\framework\gii\generators\model\views\index.php")
#7 + X:\home\test1.ru\framework\web\CBaseController.php(96): CBaseController->renderInternal("X:\home\test1.ru\framework\gii\generators\model\views\index.php", array("model" => ModelCode), true)
#8 + X:\home\test1.ru\framework\web\CController.php(870): CBaseController->renderFile("X:\home\test1.ru\framework\gii\generators\model\views\index.php", array("model" => ModelCode), true)
#9 + X:\home\test1.ru\framework\web\CController.php(783): CController->renderPartial("index", array("model" => ModelCode), true)
#10 + X:\home\test1.ru\framework\gii\CCodeGenerator.php(73): CController->render("index", array("model" => ModelCode))
#11 + X:\home\test1.ru\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
#12 + X:\home\test1.ru\framework\web\CController.php(309): CInlineAction->runWithParams(array())
#13 + X:\home\test1.ru\framework\web\CController.php(287): CController->runAction(CInlineAction)
#14 + X:\home\test1.ru\framework\web\CController.php(266): CController->runActionWithFilters(CInlineAction, array())
#15 + X:\home\test1.ru\framework\web\CWebApplication.php(283): CController->run("")
#16 + X:\home\test1.ru\framework\web\CWebApplication.php(142): CWebApplication->runController("gii/model")
#17 + X:\home\test1.ru\framework\base\CApplication.php(162): CWebApplication->processRequest()
#18 – X:\home\test1.ru\subdomain\index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
Код скрипта:#1 – X:\home\test1.ru\subdomain\protected\components\PhpAuthManager.php(16): CWebUser->__get("role")
Код: Выделить всё
<?php
class PhpAuthManager extends CPhpAuthManager{
public function init(){
// Иерархию ролей расположим в файле auth.php в директории config приложения
if($this->authFile===null){
$this->authFile=Yii::getPathOfAlias('application.config.auth').'.php';
}
parent::init();
// Для гостей у нас и так роль по умолчанию guest.
if(!Yii::app()->user->isGuest){
// Связываем роль, заданную в БД с идентификатором пользователя,
// возвращаемым UserIdentity.getId().
$this->assign(Yii::app()->user->role, Yii::app()->user->id); //!!! <<<<<<<<<<<<< ВОТ ЭТА СТРОКА 16
}
}
}
И ещё, нужное место из конфига:Controller Generator
Crud Generator
Form Generator
Module Generator
Код: Выделить всё
'components'=>array(
'user'=>array(
'class' => 'WebUser',
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl'=>'/site/login',
),
А так всё работает, и авторизация, и "echo Yii::app()->user->role;" выводит роль как надо
И вобще как-то это странно причём здесь WebUser, у GII своя авторизация..